Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
测试数据对了,但WA掉了,帮忙看看哪里错了,谢谢喽!!!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator