解题思路:
注意事项:
参考代码:
#include<iostream>
int s(double );
int main(){
using std::cout;
using std::cin;
double a;
cin>>a;
int n=s(a);
switch(n){
case 1:printf("%.2f",a*0.1);break;
case 2:printf("%.2f",10000+(a-100000)*0.075);break;
case 3:printf("%.2f",17500+(a-200000)*0.05);break;
case 4:printf("%.2f",27500+(a-400000)*0.03);break;
case 5:printf("%.2f",33500+(a-600000)*0.015);break;
case 6:printf("%.2f",39500+(a-1000000)*0.01);break;
default:cout<<"请输入大于零的数:";
}
return 0;
}
int s(double t){
if(t<0) return 0;
else if(t<=100000.0) return 1;
else if(t<=200000.0) return 2;
else if(t<=400000.0) return 3;
else if(t<=600000.0) return 4;
else if(t<=1000000.0) return 5;
else return 6;
}
0.0分
1 人评分