一个关于单词计数的程序
#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;
const int size=0;
int main()
{
char ch[size];
int yuan_count=0;
int fu_count=0;
int count=0;
cout<<"enter words(q to quit):"<<endl;
cin>>ch;
while(strcmp("q",ch))
{
if(isalpha(ch[0]))
{
if(ch[0]=='a'||ch[0]=='e'||ch[0]=='i'||ch[0]=='o'||ch[0]=='u')
yuan_count++;
else
fu_count++;
}
else
count++;
cin>>ch;
}
cout<<yuan_count<<" words beginning with vowels"<<endl;
cout<<fu_count<<" wrods beginning with consonants"<<endl;
cout<<count<<" others"<<endl;
return 0;
}