cyhtpcandph 2016-07-09 04:14 采纳率: 100%
浏览 1257
已采纳

c语言if语句the c programming language 第二版练习题

#include
#include

int main()
{
int a,b;

b = 0;
while ( (a = getchar()) != EOF)
{
    if ( a == ' ')
    {
        if (b == 0)
        {
            b =1;
            putchar(a);
        };
    };
    if ( a != ' ')
    { 
        b = 0;
        putchar (a);
    };
};
system("pause");
return 0;

}
我想问的是:
if (b == 0)
{
b =1;
putchar(a);
};
这段if语句中运行到b = 1 时这段if语句会退出吗?
此题来自the c programming language 第二版中exercise 1-9 wirte a program to copy its input to its output ,replacting each string of one or more blanks by a single blank.刚学
谢谢各位了

  • 写回答

1条回答 默认 最新

  • 莫影老师 2016-07-09 05:00
    关注

    不会,程序是自上向下,进入if语句中,只有完全执行完后才能退出,除非里面遇到跳转语句

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?