如何解读下面c语言程序? 我都快被绕蒙圈了


#include 
main()
{
int x=15;
while(x<49)
 {x++;
while(x++<25)
if(x%3)
{x++;break;}
else continue;
}
printf("%d\n",x);
}

把代码格式化,首行缩进的方式,增加输出语句,查看变量变化的过程,供参考:

#include <stdio.h>
int main()
{
    int x=15;
    while(x<49)
    {
        x++;
        printf("1:x=%d\n",x);
        while(x++<25){
            printf("2:x=%d\n",x);
            if(x%3)
            {
                printf("3:x=%d\n",x);
                x++;
                break;
            }
            else
                continue;
        }
    }
    printf("%d\n",x);
    return 0;
}

img

img

img


将代码复制到VS2019调试结果如下