#include<iostream>
using namespace std;
int main()
{
char cstring[100];
int index, iword = 1;
char blank;
gets(cstring);
if (cstring[0] == '\0')
{
cout << "there is no char" << endl;
}
else
if (cstring[0] == ' ')
cout << "the first char is a blank" << endl;
else
{
for (index = 0; cstring[index] != '\0'; index++)
{
blank = cstring[index];
if (blank == ' ')
{
iword++;
}
}
cout << "the words number is " << iword << endl;
}
system("pause");
return 0;
}
字符串中单词的个数
最新推荐文章于 2021-03-16 16:17:04 发布