统计单词个数
#include<iostream>
using namespace std;
enum itsaWord{NO,YES};
int main(){
itsaWord isWord=NO;
char ch='a';
int wordcount=0;
cout<<"Enter a phrase:\n";
do{
ch=gets();
if(ch==' '||ch=='\n')
{
if(isWord==YES)
{
wordcount++;
isWord=NO;
}
}
else if(isWord==NO)
isWord=YES;
}while(ch!='\n');
cout<<"\n--Word count is "<<wordcount<<endl;
return 0;
}
编译不对,大家有没有好的办法