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 |
我也不会做吖!看我这个程序有什么问题?老是wrong answer。小弟刚学c,表达拙劣,莫笑!!!#include <stdio.h> int maxsum(int a[500],int n) { int sum=0,i,j,thissum; for (i=0;i<n ;i++ ) { thissum=0; for (j=0;j<n ;j++ ) { thissum+=a[j]; if (thissum>sum)sum=thissum; } } return sum; } int maxsum2(int a[500][500],int n) { int sum=0,i,j,k,t; int b[500],max; for (i=0;i<n ;i++ ) { for(k=0;k<n;k++)b[k]=a[i][k]; for(j=i+1;j<n;j++) { for(t=0;t<n;t++)b[t]+=a[j][t]; max=maxsum(b,n); if (max>sum)sum=max; } } return sum; } int main() { int n,sum,a[500][500],i,j; scanf("%d",&n); for(i=0;i<n;i++) for (j=0;j<n;j++) scanf ("%d",&a[i][j]); sum=maxsum2(a,n); printf("%d\n",sum); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator