应该可以这样写int main(int argc, char const *argv[])
{
int num,prize;
scanf("%d",num);
prize = 0;
switch(num/100000) {
case 10:
prize += (num - 1000000) * 0.01; // 1%
num = 1000000;
case 9:
case 8:
case 7:
case 6:
prize += (num - 600000) * 0.015; // 1.5%
num = 600000;
case 5:
case 4:
prize += (num - 400000) * 0.03; // 3%
num = 400000;
case 3:
case 2:
prize += (num - 200000) * 0.05; // 5%
num = 200000;
case 1:
prize += (num - 100000) * 0.075; // 7.5%
num = 100000;
default:
prize += num * 0.1; // 10%
break;
}
return 0;
}
|