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 |
同一个代码,为什么在G++下AC,而在C++下WA呢?(附代码)#include<iostream> using namespace std; int main() { int n,ans; int i,j,k,m; int sumline[100],anss[100]; int data[100][100]; cin>>n; ans=-127; for (i=0;i<n;i++) for (j=0;j<n;j++) cin>>data[i][j]; for (i=0;i<n;i++) for (j=i;j<n;j++) { for (k=0;k<n;k++) { anss[k]=0; sumline[k]=0; } for (k=0;k<n;k++) { for (m=i;m<=j;m++) sumline[k]+=data[m][k]; if (anss[k]>=0) anss[k+1]=anss[k]+sumline[k]; else anss[k+1]=sumline[k]; if (anss[k+1]>ans) ans=anss[k+1]; } } cout<<ans<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator