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

路过的 帮忙看那看哪里错了

Posted by shiweixiong at 2012-09-10 17:32:58 on Problem 2533
#include<stdio.h>
int a[1010];
int d[1010];
int max(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
int main()
{
	int i,n,mmax,j;
	
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
		{
			printf("1\n");
			continue;
		}
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			d[i]=0;
		}
        d[0]=1;
		for(i=1;i<n;i++)
		{
			for(j=0;j<i;j++)
				if(a[i]>a[j])
					d[i]=max(d[i],d[j]+1);
		}
		mmax=d[0];
		for(i=0;i<n;i++)
			if(d[i]>mmax)
				mmax=d[i];
			printf("%d\n",mmax);
	}
	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