[NOIP1998]阅读程序,输出maxx的值是多少?
作者:野牛程序员:2023-10-01 08:38:22题目阅读 3243
#include <iostream>
#include <cstdio>
#include<cmath>
using namespace std;
int s,maxx;
int a[11];
int main()
{
for(int i=1; i<=10; ++i) cin>>a[i];
maxx= a[1];
s =a[1];
for(int i=2; i<=10; ++i)
{
if(s<0) s=0;
s=s+a[i];
if(s>maxx) maxx=s;
}
printf("%d",maxx);
return 0;
}样例输人:
8 9 -1 24 6 5 11 15 -28 9
输出maxx的值是多少?
野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892

