#include <iostream>
#include <cctype>
#include <cstring>
int main() {
using namespace std;
char ch[10];// insert code here...
int n_vo=0;
int n_con=0;
int n_other=0;
cout<<"Enter words (q to quit):"<<endl;
cin>>ch;
while(strlen(ch)!=1||(strlen(ch)==1&&ch[0]!='q'))
{
if(strchr("AaEeIiOoUu",ch[0]))
++n_vo;
else if(isalpha(ch[0]))
++n_con;
else
++n_other;
cin>>ch;
}
cout<<n_vo<<" words beginning with vowels"<<endl;
cout<<n_con<<" words beginning with consonants"<<endl;
cout<<n_other<<" others"<<endl;
return 0;
}
C++ primer plus 6th 第六章6.7 编程答案
最新推荐文章于 2024-11-09 13:08:09 发布