您的位置:首页 > 编程语言 > C语言/C++

编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7

2013-12-02 22:51 417 查看
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string words;
int yy=0;
int fy=0;
int other=0;
cout<<"Enter words (q to quit):\n";
while(cin>>words)
{
if(isalpha(words[0]))
{
if(words[0]=='q' && (words.size())==1)
break;
else
{
switch(words[0])
{
case 'a':
case 'o':
case 'e':
case 'i':
case 'u':
yy++;
break;
default:fy++;
}
}
}
else
other++;
}
cout<<yy<<" words beginning with vowels"<<endl;
cout<<fy<<" words beginning with consonants"<<endl;
cout<<other<<" others"<<endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐