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 |
一次AC,不为别的,只想问问大家我的代码可读性强不?#include <iostream> #include <string.h> using namespace std; bool VorC(char c) { if((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) return true; return false; } bool Rule1(char s[]) { int i; for(i=0; i<strlen(s); i++) if(VorC(s[i])) return true; return false; } bool Rule2(char s[]) { int i; if((strlen(s) == 1) || (strlen(s) == 2)) return true; for(i=0; i<strlen(s)-2; i++) { if(VorC(s[i]))//Is Vowel { if(VorC(s[i+1])) if(VorC(s[i+2])) return false; } else//Is Consonant { if(!VorC(s[i+1])) if(!VorC(s[i+2])) return false; } } return true; } bool Rule3(char s[]) { int i; for(i=0; i<strlen(s)-1; i++) if((s[i] == s[i+1]) && (s[i] != 'e') && (s[i] != 'o')) return false; return true; } int main() { char s[21]; cin>>s; while(strcmp(s, "end")) { if(Rule1(s)) if(Rule2(s)) if(Rule3(s)) { cout<<"<"<<s<<"> is acceptable."<<endl; cin>>s; continue; } cout<<"<"<<s<<"> is not acceptable."<<endl; cin>>s; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator