题解 | #计算商品打折结算金额#
计算商品打折结算金额
https://www.nowcoder.com/practice/055a92b5c93f497291a58c232f59fae9
#include<stdio.h> int main(){ float price; scanf("%f", &price); // 从用户那里获取价格 if(price>=100&&price<500){ price = price*0.9; } else if (price>=500&&price<2000) { price = price*0.8; }else if (price>=2000&&price<5000) { price = price*0.7; } else if (price>=5000) { price = price*0.6; }//这里不需要else分支,100元内价格不变,否则代码冗余 printf("%.1f",price); return 0; }