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 dgsrz at 2012-01-13 15:01:32 on Problem 1575
#include<iostream>
#include<cstring>
using namespace std;

char vowel[5]={'a','e','i','o','u'};

int isVowel(char c)
{
	for(int i=0;i<5;i++)
		if(c==vowel[i])
			return 1;
	return 0;
}

int main()
{
	char word[100];
	while(cin>>word,strcmp(word,"end")!=0)
	{
		int tVowel=0,accepted,length=strlen(word);
		for(int i=0;i<length;i++)
		{
			int cVowel=0,cOther=0,fVowel=0,fOther=0;

			//判断是否为原音字母
			fVowel=(isVowel(word[i]));
			fOther=(fVowel)?0:1;

			if(fVowel)
				tVowel++;

			for(int j=0;j<3&&i+j<length;j++)
			{
				if(isVowel(word[i+j]))
					cVowel++;
				else
					cOther++;
				if(j>0&&word[i+j]==word[i])
					if(word[i]!='e'&&word[i]!='o')
					{
						accepted=0;
						goto finish;
					}
			}
			accepted=(cVowel==3||cOther==3)?0:1;
			if(!accepted)
				break;
		}
		if(tVowel==0)
			accepted=0;
		finish:
		printf("<%s> is%s acceptable.\n",word,(accepted)?"":" not");
	}
	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