int main()
{
int i = 0;
char ch;
do
{
scanf("%c", &ch);
if (ch == ' ')
{
i++;
}
} while (ch == '\n');
printf("%d", i+1);
return 0;
}
为什只有一次循环 输入(Let's go to room 209.)i=1
)
while循环条件是 回车符,没有回车符所以执行一次
C和C++完整教程:https://blog.csdn.net/it_xiangqiang/category_10581430.html
C和C++算法完整教程:https://blog.csdn.net/it_xiangqiang/category_10768339.html