直达要害,一针见血,14行代码统计英语单词个数。
#include <iostream>
using namespace std;
int main()
{
int a ,numb1=0;
cout<<"请输入一串字符(以一个空格为分隔不同单词)"<<endl;
while ((a=getchar())!='\n')
{
if(a==' '&&a!=' '||a=='\n')
numb1++;
}
numb1+=1;
cout<<numb1<<endl;
system("pause");
}