文章
11
粉丝
0
获赞
13
访问
641
#include <stdio.h>
int main() {
int profit;
float bonus = 0;
scanf("%d", &profit);
const int thresholds[] = {100000, 100000, 200000, 200000, 400000, 1000000};
const float rates[] = {0.10f, 0.075f, 0.05f, 0.03f, 0.015f, 0.01f};
int remaining = profit;
for (int i = 0; i < 6; ++i) {
if (remaining <= 0) break;
int current = (remaining > thresholds[i]) ? thresholds[i] : remaining;
bonus += current * rates[i];
remaining -= thresholds[i];
}
if (remaining > 0) {
bonus += remaining * 0.01f;
}
printf("%g", bonus);
return 0;
}
登录后发布评论
暂无评论,来抢沙发