c++:输入一行字符统计其中单词个数,单词间用空格分开。当单词间空格数为多个时怎么改?
#include<stdio.h>intmain(void){intcount;charch;printf("entern:\n");count=1;while((ch=...
#include<stdio.h>
int main(void)
{
int count;
char ch;
printf("enter n:\n");
count=1;
while((ch=getchar())!='\n'){
while(ch==' '){
count++;
break;
}
}
printf("%d\n",count);
return 0;
} 展开
int main(void)
{
int count;
char ch;
printf("enter n:\n");
count=1;
while((ch=getchar())!='\n'){
while(ch==' '){
count++;
break;
}
}
printf("%d\n",count);
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询