题解 | #计算商品打折结算金额#
计算商品打折结算金额
https://www.nowcoder.com/practice/055a92b5c93f497291a58c232f59fae9
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double price;
cin >> price;
double cost = 0.0;
cost = price;//赋值
// write your code here.......
if (cost >=100 && cost <500)
{
cost *= 0.9;
}
if (cost >= 500 && cost < 2000)
{
cost *= 0.8;
}
if (cost >=2000 && cost <5000)
{
cost *= 0.7;
}
else if (cost >= 5000)
{
cost *= 0.6;
}
cout << setiosflags(ios::fixed) << setprecision(1) << cost << endl;
return 0;
}
C语言基础 文章被收录于专栏
里面较为详细的介绍了c语言的相关用法和有关题目。
查看13道真题和解析