1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include#include using namespace std; int main() { int YuanYin = 0; int FuYin = 0; int Others = 0; char str[80]; bool end = false; cout << ”Enter words(q to exit) : /n”; while (cin>>str && false == end ) / / { if (isalpha(str[0]) > 0) { switch (str[0]) { case‘a’: case‘o’: case‘e’: case‘i’: case‘u’: case‘A’: case‘O’: case‘E’: case‘I’: case‘U’: ++YuanYin; break; case‘q’: if (strlen(str) == 1) { end = true; break; } default: ++FuYin; } if (end) break; continue; }++Others; } cout << YuanYin << ”words beginning with vowel / n”; cout << FuYin << ”words beginning with consonants / n”; cout << Others << ”others / n”; return 0; }
|