题目
描述:
简要描述:企业发放的奖金根据利润提成。
利润低于或等于100000元的,奖金可提10%;
利润高于100000元,低于200000元(100000≤200000)时;
低于100000元的部分按10%提成;
高于100000元的部分,可提成7.5%;
200000≤400000时,低于200000元部分仍按上述办法提成,(下同);
高于200000元的部分按5%提成;
400000≤600000元时,高于400000元的部分按3%提成;
600000≤1000000时,高于600000元的部分按1.5%提成;
I>1000000时,超过1000000元的部分按1%提成。
从键盘输入当月利润I,求应发奖金总数。
输入:
一个整数,当月利润。
输出:
一个整数,奖金。
例如:
输入900
输出90
备注:奖金向下取整,不作四舍五入处理。
练习阶段:
初级
代码
#include <iostream>
#include "oj.h"
using namespace std;
#include <stdlib.h>
#include <stdio.h>
size_t Bonus(size_t profit){
size_t result = 0;
while(profit){
if(profit <= 100000){
result += profit * 0.1;
return result;
}
else if(profit <= 200000){
result += (profit - 100000) * 0.075;
profit = 100000;
}
else if(profit <= 400000){
result += (profit - 200000) * 0.05;
profit = 200000;
}
else if(profit <= 600000){
result += (profit - 400000) * 0.03;
profit = 400000;
}
else if(profit <= 1000000){
result += (profit - 600000) * 0.015;
profit = 600000;
}
else{
result += (profit - 1000000) * 0.01;
profit = 1000000;
}
}
return result;
}
<script type="text/javascript">
$(function () {
$('pre.prettyprint code').each(function () {
var lines = $(this).text().split('\n').length;
var $numbering = $('<ul/>').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('<li/>').text(i));
};
$numbering.fadeIn(1700);
});
});
</script>
分享到:
相关推荐
华为机试一霸教你过华为机试演讲稿..pdf
华为OD机试(..75.rar
华为机试真题(非牛客网试练题)OD考试真题,不定期更新,文档含代码解答
华为机试一霸教你过华为机试.doc
华为机试一霸教你过华为机试。大菊厂招聘有三关,心理测试,机试,面试。
。。。
。。。
华为机试算法题总结 经验分享
华为机试oj练习题2014
华为机试一霸教你过华为机试e-18页.pdf
本人在准备2014年华为机试的时候,进行整理的,代码全部运行成功。如有错误,请大家见谅。
华为OD系列--华为OD机试
华为机试题目100题练习题
华为机试成功归来,与小伙伴们分享下经验
大师兄教你如何过华为机试
贰壹贰叁零华为OD机试.pptx 华为OD机试.pptx 华为OD机试.pptx
华为机试.md
里面有几十道华为历届考过的机试题,可供大家研究和参考,主要是里面的思想,只要理解透了里面的思想,非常有助于机试。
2014重邮华为机试(2013.9.14和2013.9.15)一共三场的题目
华为机试.py