解题思路:宏定义
注意事项:
参考代码:
#include"stdio.h"
#define A 100000
#define B 200000
#define C 400000
#define D 600000
#define E 1000000
#define J1 0.1
#define J2 0.075
#define J3 0.05
#define J4 0.03
#define J5 0.015
#define J6 0.01
#define SW (A*J1) //<=10w
#define REW (SW+(B-A)*J2) //<=20w
#define SIW (REW+(C-B)*J3) //<=40w
#define LW (SIW+(D-C)*J4) //<=60w
#define YW (LW+(E-D)*J5) //<=100w
int main()
{
int x,y;
scanf("%d",&x);
if(x<=A)
y=x*J1;
else if(x<=B)
y=SW+((x-A)*J2);
else if(x<=C)
y=REW+((x-B)*J3);
else if(x<=D)
y=SIW+((x-C)*J4);
else if(x<=E)
y=LW+((x-D)*J5);
else if(x>E)
y=YW+((x-E)*J6);
printf("%d",y);
return 0;
}
0.0分
0 人评分