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();
}
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();
}
阅读全文
0 0
- c++102页第三题。用if-else,switch实现分层业绩奖励
- 分别用if else 以及 switch实现 税收计算
- C语言 if...else PK switch...case
- 通用switch-case/if-else实现
- if else 与switch 效率&实现机制
- switch 与 if/else
- if()else + switch用法
- switch 与 if else
- C语言中switch case语句的实现(switch case 和 else if 的比较、区别)
- if.....else if .....else 与switch....case.....
- C语言之if...else PK switch...case
- C/OC 语言 if else 和switch 哪个更效率
- switch和if-else相比
- switch和if-else相比
- switch case 与 if else
- switch和if-else相比
- switch和if-else相比
- switch与if..else区别
- C++—string类写实拷贝的实现
- 6.Python的基本数据类型(中)
- Python 设计模式
- [webpack]path、publicPath、--content-base 理解
- SQL基础语句
- c++102页第三题。用if-else,switch实现分层业绩奖励
- 架构漫谈
- Linux系统安装Tomcat
- vue Devtools无法使用的原因
- Java
- log4j.properties详细配置文档
- javac运行过程
- Android面试题
- 第九章项目二 二叉树遍历的递归算法