#include<iostream>
#include<cstring>
#include<cctype>
int main()
{
using namespace std;
char word[20];
cout<<"Enter words (q to quit):"<<endl;
cin>>word;
int vowel,consonants,others;
vowel=consonants=others=0;
while(strcmp(word,"q"))
{
if(isalpha(word[0]))
{
switch(word[0])
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U': vowel++;
break;
default : consonants++;
}
}else{
others++;
}
cin>>word;
}
cout<<vowel<<" words beginning with vowels."<<endl;
cout<<consonants<<" beginning with consonants."<<endl;
cout<<others<<" others."<<endl;
return 0;
}
C++ Primer Plus 6.11_7
最新推荐文章于 2024-08-17 23:59:05 发布