#include<stdio.h>
main()
{int s,t,m;
scanf("%d",&s);
t=(int)(s/10);
switch(t)
{ case 10: m=5;break;
case 9: m=4;break;
case 8: m=3;break;
case 7: m=2;break;
case 6: m=1;break;
default: m=0;}
printf("%d",m);
}
switch那段改成下面这样:
if (t == 10)m=5;
else if (t == 9)
m=4;
else if (t == 8)
m=3;
else if (t == 7)
m=2;
else if (t == 6)
m=1;
else
m=0;
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-11-02
#include<stdio.h>
main()
{int s,t,m;
scanf("%d",&s);
t=(int)(s/10);
int flag = 0;
if(10 == t)
m =5,flag =1;
if(9 == t&&flag ==0)
m =4,flag=1;
if(8 == t&&flag ==0)
m =3,flag=1;
if(7 == t&&flag ==0)
m =2,flag=1;
if(6 == t&&flag ==0)
m =1,flag=1;
if(flag == 0)
m =0;
printf("%d",m);
}本回答被网友采纳
main()
{int s,t,m;
scanf("%d",&s);
t=(int)(s/10);
int flag = 0;
if(10 == t)
m =5,flag =1;
if(9 == t&&flag ==0)
m =4,flag=1;
if(8 == t&&flag ==0)
m =3,flag=1;
if(7 == t&&flag ==0)
m =2,flag=1;
if(6 == t&&flag ==0)
m =1,flag=1;
if(flag == 0)
m =0;
printf("%d",m);
}本回答被网友采纳