ECNU1109
View Code
1 #include<stdio.h> 2 int a[105]; 3 int main() 4 { 5 int t,i,j,n,max,thismax;//,num=0;//p1,p2; 6 scanf("%d",&t); 7 while(t--) 8 { 9 scanf("%d",&n); 10 //num++; 11 //p1=1;p2=1; 12 for(i=0;i<n;i++) 13 scanf("%d",&a[i]); 14 max=a[0]; 15 for(i=0;i<n;i++) 16 { 17 thismax=0; 18 for(j=i;j<n;j++) 19 { 20 thismax=thismax+a[j]; 21 if(thismax>max) 22 { 23 //p1=i+1; 24 //p2=j+1; 25 max=thismax; 26 } 27 } 28 } 29 //printf("Case %d:\n",num); 30 printf("%d\n",max); 31 } 32 return 0; 33 }
keep moving...