C语言判断?

2024-12-20 05:45:40
推荐回答(2个)
回答1:

不正确,case 后面紧跟choice 的变量内容,case 1:price=30;break;

回答2:

switch(choice){
case 1: price = 3.0; break;
case 2: price = 2.5; break;
case 3: price = 4.0; break;
case 4: price = 3.5; break;
default: price = 0.0; break;
}
应该是这样,不用加判断语句