in reply to sum of continues array
What have you tried?
You could:
use strict; use warnings; my @array = (1, 2, 3, 4, -1, -2, -3, 11, 12, 13); my $max = 0; my $sum; ($a = ($_ > 0 ... $b + 1 != $_)), ($a and $a == 1 and $sum = 0), ($a and $a !~ /E0/ and $sum += $b = $_), ($a and $sum > $max and $max = $sum) for @array; print $max;
which prints 36, but your teacher may not like that.
|
|---|