#include <stdio.h>
#include <stdlib.h>

int main(void){
    int lumens;
    int watts;

    printf("please enter Watts\n");
    scanf("%d",watts);

    switch (watts) {
        case 15:
            lumens=125;
            printf("%d\n", lumens);
            break;
        case 25:
            lumens=215;
            printf("%d\n", lumens);
            break;
        case 40:
            lumens=500;
            printf("%d\n", lumens);
            break;
        case 60:
            lumens=880;
            printf("%d\n", lumens);
            break;
        case 75:
            lumens=1000;
            printf("%d\n", lumens);
            break;
        case 100:
            lumens=1675;
            printf("%d\n", lumens);
            break;
        default:
            lumens=(-1);
            printf("%d\n", lumens);
    }

    return 0;
}


在我看来,它似乎不运行切换语句?但是我不明白

最佳答案

scanf应该是

printf("please enter Watts\n");
scanf("%d",&watts);

关于c - 为什么我的C程序停止运行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26140539/

10-14 07:23