解题思路:
这其实就是if语句的理解
注意事项:
还有更快的写法,利润到了某一档时,它前面的奖金是固定的,不用去计算了
参考代码:
#include <stdio.h>
int CalculateReward(int Profit);
int main(void)
{
int profit = 0;
scanf("%d",&profit);
int reward = CalculateReward(profit);
printf("%d\n",reward);
return 0;
}
int CalculateReward(int Profit)
{
int re = 0;
if(Profit > 1000000)
{
re = (Profit - 1000000) / 100;
Profit = 1000000;
}
if(Profit > 600000 && Profit <= 1000000)
{
re += (Profit - 600000) * 15 / 1000;
Profit = 600000;
}
if(Profit > 400000 && Profit <= 600000)
{
re += (Profit - 400000) * 3 / 100;
Profit = 400000;
}
if(Profit > 200000 && Profit <= 400000)
{
re += (Profit - 200000) * 5 / 100;
Profit = 200000;
}
if(Profit > 100000 && Profit <= 200000)
{
re += (Profit - 100000) * 75 / 1000;
Profit = 100000;
}
if(Profit <= 100000)
{
re += Profit / 10;
}
return re;
}
0.0分
0 人评分
C语言训练-大、小写问题 (C语言代码)浏览:724 |
WU-整数平均值 (C++代码)浏览:1239 |
【蟠桃记】 (C语言代码)浏览:1021 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:460 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:586 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:537 |
神奇的fans (C语言代码)浏览:979 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:839 |
拆分位数 (C语言代码)浏览:441 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:556 |