#include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF&&n!=0) { int a[n],i; for(i=0;i<n;i++) { scanf("%d",&a[i]); } int max=a[0]; int s; for(i=0;i<n;i++){ s=0; for(j=i;j<n;j++) { s+=a[j]; if(s>max) max=s; } } printf("%d\n",max); } return 0; } /* Main.c: In function 'main': Main.c:16:8: error: 'j' undeclared (first use in this function) for(j=i;j<n;j++) ^ Main.c:16:8: note: each undeclared identifier is reported only once for each function it appears in */ |
Double click to view unformatted code.