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 lishiyu1314 at 2009-08-18 17:10:29 on Problem 1050
#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:
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