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 771385494 at 2011-10-29 19:21:08 on Problem 1575
#include <iostream>
#include <cstring>
using namespace std;
char vowels[5] = {'a','e','i','o','u'};
int isvowel(char ch)
{	int i = 0;
	for(i = 0;i < 5;i++)
		if(ch == vowels[i])
			return 1;
	return 0;
}
int rule1(char array[],int n)
{
	int i = 0;
	for(i = 0;i < n;i++)
		if(isvowel(array[i]) == 1)
			return 1;
	return 0;
}
int rule2(char array[],int n)
{
	int i = 0;
	for(i = 0;i < n - 2;i++){
		if(isvowel(array[i]) == 1){
			if((isvowel(array[i + 1]) == 1) && (isvowel(array[i + 2]) == 1))
				return 0;
		}
		else{
			if((isvowel(array[i + 1]) == 0) && (isvowel(array[i + 2]) == 0))	
				return 0;
		}
	}
	return 1;		
}
int rule3(char array[],int n)
{	
	int i = 0;
	for(i = 0;i < n - 1;i++)
		if((array[i + 1] == array[i]) && (array[i] != 'e') && (array[i] != 'o'))
			return 0;
	return 1;
}
int main()
{
	char str[22];
	cin >> str;
	while(cin >> str && strcmp(str,"end") != 0){
		int length = strlen(str);
		if(length == 1){
			if(isvowel(str[0]) == 1)
				cout << "<" << str << "> is acceptable.\n";
			else
				cout << "<" << str << "> is not acceptable.\n";
		}
		else{
			if(rule1(str,length) == 1 && rule3(str,length) == 1){
				if(length >= 3){
					if(rule2(str,length) == 1)
						cout << "<" << str << "> is acceptable.\n";
					else
						cout << "<" << str << "> is not acceptable.\n";
				}
				else
					cout << "<" << str << "> is acceptable.\n";
			}
			else
				cout << "<" << str << "> is not acceptable.\n";
		}
		memset(str,0,22);
	}
	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