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 |
大家帮帮忙吧!我测试过得呀!没有错啊!为什么交上去就WA了?有代码?#include<iostream> using namespace std; int qiumax(int *a,int n) { int max=0,aa=0; for(int i=0;i<n;i++) { if(aa>0) aa+=a[i]; else aa=a[i]; if(aa>max) max=aa; } return max; } int erweimax(int **a,int n) { int *b=NULL; b=new int[n]; int sum=0,max=0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { b[j]=0; } for(int k=i;k<n;k++) { for(int m=0;m<n;m++) { b[m]+=a[k][m]; sum=qiumax(b,n); if(sum>max) max=sum; } } } delete []b; b=NULL; return max; } int main() { int N; cin>>N; int **a; a=new int*[N]; for(int k=0;k<N;k++) { a[k]=new int[N]; if(a[k]==NULL) exit(1); } for(int i=0;i<N;i++) { for(int j=0;j<N;j++) { cin>>a[i][j]; } } int max; max=erweimax(a,N); cout<<max; cout<<endl; for(int ii=0;ii<N;ii++) { delete []a[ii]; a[ii]=NULL; } delete []a; a=NULL; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator