Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我也不会做吖!看我这个程序有什么问题?老是wrong answer。小弟刚学c,表达拙劣,莫笑!!!

Posted by humanbeing at 2003-10-11 18:16:01 on Problem 1050
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator