69,381
社区成员
发帖
与我相关
我的任务
分享
int main()
{
char str[100];
int k,space=0;
printf("\nPlease enter a sentence: \t\n\n\n\t\t\t\t");
gets(str); //读一个字符串
fflush(stdin);
//统计空格个数
for (k = 0 ; str[k] != '\0' ; k++)
{
if (str[k] == ' ')
{
space++;
}
}
cout<<space<<endl;
}