#include<iostream>
#include<cctype>
#include<cstdlib>//support for exit(),atoi()
#include<string>
#include<fstream>//文件I/O
#include<sstream>//stringstream转换各种数据格式
using namespace std;
void main()
{
string str;
int vowel=0,consonant=0,other=0;//vowel元音,consonant辅音
cout<<"enter words (q to quit):"<<endl;
cin>>str;
while("q"!=str)
{
if(isalpha(str[0]))
{
if(('a'==str[0])||('o'==str[0])||('e'==str[0])||('i'==str[0])||('o'==str[0])||('u'==str[0]))//判断是否元音
vowel++;
else
consonant++;
}
else
other++;
cin>>str;
}
cout<<vowel<<" words beginning with vowels"<<endl;
cout<<consonant<<" words beginning with consonants"<<endl;
cout<<other<<" others"<<endl;
}
C++primer plus第六版课后编程练习答案6.7
最新推荐文章于 2019-03-07 18:28:12 发布