C语言判断?
设变量已正确定义,以下是合法的switch语句吗?谢谢switch(choice){casechoice==1:price=3.0;break;casechoice==2...
设变量已正确定义,以下是合法的switch语句吗?谢谢
switch(choice){
case choice == 1: price = 3.0; break;
case choice == 2: price = 2.5; break;
case choice == 3: price = 4.0; break;
case choice == 4: price = 3.5; break;
default: price = 0.0; break;
} 展开
switch(choice){
case choice == 1: price = 3.0; break;
case choice == 2: price = 2.5; break;
case choice == 3: price = 4.0; break;
case choice == 4: price = 3.5; break;
default: price = 0.0; 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;
}
应该是这样,不用加判断语句
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;
}
应该是这样,不用加判断语句
追问
那我这个是对的吗?判断题啊,我不知道对不对
追答
应该的和你的不一样,当然就不对了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询