“21天养成好习惯”-14
今天学习了如何进行奖金计算
#include <stdio.h>
int main()
{
long int a,b,x,w;
scanf("%ld",&x);
if(x<=100000)
{
w=0.1*x;
}
else if(x>100000&&x<=200000)
{
w=10000+0.075*(x-100000);
}
else if(x>200000&&x<=400000)
{
w=10000+0.075*100000+(x-200000)*0.05;
}
else if(x>400000&&x<=600000)
{
w=10000+0.075*100000+200000*0.05+(x-400000)*0.03;
}
else if(x>600000&&x<=1000000)
{
w=10000+0.075*100000+200000*0.05+200000*0.03+(x-600000)*0.015;
}
else
{
w=10000+0.075*100000+200000*0.05+200000*0.03+400000*0.015+(x-1000000)*0.01;
}
printf("bonus=%ld\n",w);
return 0;
}
运行结果如下:
15252
bonus=1525
--------------------------------
Process exited after 2.741 seconds with return value 0
请按任意键继续. . .
1056526
bonus=40065
--------------------------------
Process exited after 2.84 seconds with return value 0
请按任意键继续. . .