解题思路:依据题意,该题可以简单的分成6种情况,用switch语句作为选择语句比较方便,参考代码如下:
#include<stdio.h> int main() { long profit, bonus = 0; scanf("%ld", &profit); if (profit <= 1000000) { switch ((profit - 1) / 100000) { case 0:bonus = profit * 0.1; break; case 1:bonus = 10000 + (profit - 10000) * 0.075; case 2: case 3: { bonus = 17500 + (profit - 200000) * 0.05; } case 4: case 5: { bonus = 27500 + (profit - 400000) * 0.03; } case 6: case 7: case 8: case 9: { bonus = 33500 + (profit - 600000) * 0.015; } } if (profit > 1000000) { bonus = 39500 + (profit - 1000000) * 0.001; } printf("%ld", bonus); } }
0.0分
3 人评分