|
|
back to boardTest #6. Whats wrong? main() { int n,i; long a[1001],maxsum=0,nsum,nmaxsum,sum=0; scanf ("%d",&n); for (i=0; i<n; i++) { scanf ("%ld",&a[i]); if (i>=2) { if (a[i-2]==a[i-1] && a[i-1]==a[i]) { sum=a[i-2]+a[i-1]+a[i]; nsum=i; }
if (sum>=maxsum) { maxsum=sum; nmaxsum=nsum; } }
} printf ("%ld %d",maxsum, nmaxsum);
} |
|
|