- or download this
#! perl
use strict;
...
printf "Sum of all: %d\n", sum0 @array;
printf "Sum of positive: %d\n", sum0 @{ $part[1] };
printf "Sum of negative: %d\n", sum0 @{ $part[0] };
- or download this
17:47 >perl 1384_SoPW.pl
Order of array: -87 -51 -4 -1 1 3 4 7 47
...
Sum of negative: -143
17:47 >
- or download this
for (@array){ #\sum of all numbers HERE sumAll
$sumAll +=$_;
}
- or download this
$sumAll += $_ for @array;