#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; }