#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char a[100] ;
cin.getline(a, 100);
int i = 0;
int cnt = 0;
while (a[i] == ' ') i++;
while (a[i] != '\0')
{
i++;
while (a[i] != ' '&&a[i]!='\0') i++;
cnt++;
}
cout << cnt;
return 0;
}
统计一行中单词的个数
最新推荐文章于 2023-04-11 18:18:00 发布