#include <iostream>
#include <string>
using namespace std;
int main(void){
char line[518];
int i = 0;//数组下标
int count = 0;//单词计数
cout << "请输入单词:";
gets_s(line,sizeof(line));
while(line[i] == ' ') i++;
while(line[i]){
while(line[i] && line[i] !=' ') i++;
while(line[i] == ' ') i++;
count ++;
}
cout << "一共有" << count << "个单词" << endl;
system ("pause");
return 0;
}