题目: |
program ex1;
Var i,s,max:integer;
A:array[1..10] of integer;
Begin
For i:=1 to 10 do read(a[i]);
Max:=a[1]; s:=a[1];
For i:=2 to 10 do
Begin
If s<0 then s:=0;
s:=s+a[i];
If s>max then max:=s;
End;
Writeln(‘max=’,max);
End.
输入:-1 16 24 6 7 8 –18 -6 15 34
输出:max=86
|