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

终于AC,用递归实现

Posted by cugjzy at 2009-03-13 18:10:40 on Problem 1126
#include "stdio.h"
#include "string.h"
int IsCorrect(char *s,int start,int end)
{
	int i;
	if(end==start)
	{
		if(s[start]<='z'&&s[start]>='p')
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else if(s[start]=='N'&&IsCorrect(s,start+1,end))
	{
		return 1;
	}
	else if(s[start]<='E'&&s[start]>='C'||s[start]=='I')
	{
		for(i=1;i<end-start;i++)
		{
			if(IsCorrect(s,start+1,start+i)&&IsCorrect(s,start+i+1,end))
			{return 1;}
		}
		 return 0;
	}
	else
	{
		return 0;
	}

}
int main()
{
	int len,i;
	char s[260];
	while((scanf("%s",s))!=EOF)
	{
		len=strlen(s);
		i=IsCorrect(s,0,len-1);
		if(i==1)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	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