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

哪位牛人帮我看一下程序为什么会WA

Posted by 200630740415 at 2008-04-12 23:43:33 on Problem 1050
#include<iostream>
using namespace std;
int n;
int dfs(int *c)
{
	int d[100];
	int i,max=c[0];
	d[0]=c[0];
	for(i=0;i<n;i++)
	{
		if(d[i-1]<0)   {d[i]=c[i];if(max<d[i])max=d[i];}
		else {d[i]=d[i-1]+c[i];if(max<d[i])max=d[i];}
	}
	return max;
}
int main()
{
	freopen("in.txt","r",stdin);
	int i,j,a[100][100],k,ll,l,b[100];
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[i][j];
		ll=a[0][0];
		for(i=0;i<n;i++)
			b[i]=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			b[j]=0;
		for(j=i;j<n;j++)
		{
			for(k=0;k<n;k++)
			{
				b[k]+=a[j][k];
			//	cout<<b[k]<<' ';
			}
			
			l=dfs(b);//cout<<"  ---"<<l<<endl;
			if(l>ll)  ll=l;
		}
	}
	cout<<ll<<endl;
	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