Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一直RE,帮忙看看是怎么回事#include<stdio.h> int a[130][130]; int longsum(int tmp[],int n){ int maxn=0,sum=0; for(int i=0;i<n;i++){ sum+=tmp[i]; if(sum>0){ if(sum>maxn)maxn=sum; } else sum=0; } return maxn; } int main(){ int n; int tmp[130]; while(~scanf("%d",&n)){ int maxn=0; int sig=0,x; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]); } } for(int i=n;i>0;i--){ for(int j=0;j<i;j++){ for(int m=0;m<n;m++){ tmp[m]=a[j][m]; } x=j+1; for(int k=0;k<sig;k++){ for(int m=0;m<n;m++){ tmp[m]+=a[x][m]; } x++; } if(maxn<longsum(tmp,n)){ maxn=longsum(tmp,n); } sig++; } } printf("%d\n",maxn); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator