
void main()
{
int age
printf("please input the child age:"脊睁)
scanf("%d",&age)
switch(age)
{
case 2:
case 3: printf("%d,enter the Lower class.\n",age)break
case 4: printf("%d,enter the Middle class.\n",age)break
case 5:
case 6: printf("樱拿岁敏局%d,enter the Higher class.\n",age)break
default : printf(" you chlid shuld goto more Higher class.\n")break
}
}
肯定可以的,只要你程序橘洞告是对的,这个又不相互影响,switch是和case一起使用的,还有break你可以圆明还一下你的c语言书上是怎么写的,你那个程序switch括弧里面那样写好像是不行的,就算不报错,但是应该不能输出正确颤链答案
#include"math.h"拆搭main()
{
float p,d,f
printf("please inout consumption\袜御老n")
scanf("%f",&p)
if(p<100)
{m==0
f=p}
else if(p>告升=100&&p<200)
{m==o.o5
f=(1-0.05)*p}
else if(p>=200&&p<500)
{m==0.1
f=(1-0.1)*p}
else if(p>=500&&p<1000)
{m==0.15
f=(1-0.15)*p}
else(p>=1000)
{m==o.2
f=(1-0.2)*p}
printf("discount is %f,amount is %f",m,f)
}
试试看!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)