lll_jh888 发表于 2020-6-22 14:57:40

为什么我的程序编译运行成功,但是输入之后没有反应

#include <stdio.h>
#define SEC_PER_MIN 60
int main(void)
{
        int sec, min, left;

        printf("Convert seconds to minutes and seconds!\n");
        printf("Enter the number of seconds (<=0 to quit):\n");
        scanf_s("%d", &sec);
        while (sec > 0);
        {
                min = sec / SEC_PER_MIN;
                left = sec % SEC_PER_MIN;
                printf("%d seconds is %d minutes, %d seconds.\n",
                        sec, min, left);
                printf("Enter next value (<=0 to quit):\n");
                scanf_s("%d", &sec);
        }
        printf("Done!\n");

        return 0;
}
求大佬帮我看看,编译运行都没问题,输入一个数之后没有反应是什么情况

wp231957 发表于 2020-6-22 15:02:33

while (sec > 0);   这个分号是什么鬼

lll_jh888 发表于 2020-6-22 16:41:38

wp231957 发表于 2020-6-22 15:02
while (sec > 0);   这个分号是什么鬼

哦!!!!!!没太注意,可能是打顺手了,编译成功我就没查这些,谢谢!!
页: [1]
查看完整版本: 为什么我的程序编译运行成功,但是输入之后没有反应