c++102页第三题。用if-else,switch实现分层业绩奖励

来源:互联网 发布:普罗米修斯软件 编辑:程序博客网 时间:2024/06/05 06:50
#include<iostream>
using namespace std;
void  main()
{
int x, c;
double  y;
cin >> x;
if (x / 1000 == 0)
c = 1;
else if (x /1000 >= 1 && x / 1000 < 5)
c = 2;
else if (x /1000 >= 5 && x / 1000 < 10)
c = 3;
else if (x / 1000 >= 10 && x / 1000 < 100)
c = 4;
else if (x / 1000 > 100)
c = 5;
switch (c)
{
case 1:y = 0.01*x, cout << y; break;
case 2:y = 0.02*x, cout << y; break;
case 3:y = 0.03*x, cout << y; break;
case 4:y = 0.04*x, cout << y; break;
case 5:y = 0.05*x, cout << y; break;




}
getchar();
getchar();




}