解题思路:大家的题解都是if语句,小白初学,想了另外一个思路,用switch语句写了也可运行,个人觉得比较简洁,希望大神们来指正一下!!!
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int x,y=0,n;
scanf("%d",&x);
switch(n=x/100000)
{
case 10: case 9: case 8:
case 7: case 6:
y=y+(x-600000)*0.015;
x=600000;
case 5: case 4:
y=y+(x-400000)*0.03;
x=400000;
case 3: case 2:
y=y+(x-200000)*0.05;
x=200000;
case 1:
y=y+(x-100000)*0.075;
x=100000;
case 0:
y=y+x*0.1;
printf("%d",y);
break;
default: //高于10w的情况
y=(x-1000000)*0.01+39500;
printf("%d",y);
break;
}
return 0;
}
0.0分
3 人评分