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 1046755480 at 2010-07-20 00:40:06 on Problem 1575
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
int Ispassword(char *str);
int vowle_consonants(char *str,int i);
int isvowle(char c);
void main()
{
	char str[21];
	while(scanf("%s",&str)!=EOF && strcmp(str,"end")!=0)
	{
		if(Ispassword(str)==1)
			printf("<%s> is acceptable.\n",str);
		else
			printf("<%s> is not acceptable.\n",str);
	}
}

int Ispassword(char *str)
{
	int i,len=strlen(str);
	if(len>=3)
	{
		for(i=0;i<len-2;i++)
		{
			if(vowle_consonants(str,i))
					return 0;
			else continue;
			
		}
		if(i>=len-2) return 1;
	}
    if(len==2)
	{
			if(!isvowle(str[0])&&!isvowle(str[1]))
				return 0;
			else if(str[0]==str[1])
			{
				if(str[0]!='e' && str[0]!='o') return 0;
				else return 1;
			}
			else return 1;
	}
	if(len==1)
	{
		if(str[0]=='a' || str[0]=='e' || str[0]=='i'|| str[0]=='o' || str[0]=='u') return 1;
		else return 0;
	}
}
int vowle_consonants(char *str,int i)
{
	if(isvowle(str[i] ) && isvowle(str[i+1] ) && isvowle(str[i+2]))
		return 1;
	 if(!isvowle(str[i]) && !isvowle(str[i+1] ) && !isvowle(str[i+2]))
		return 1;
	else if(((str[i]==str[i+1]) || (str[i+1]==str[i+2])) && (str[i+1]!='e'&&str[i+1]!='o'))return 1;
	else return 0;
}
int isvowle(char c)
{
	if(c=='a'|| c=='e'||c=='i'||c=='o'||c=='u')
		return 1;
	else 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