标签:disco scanf double problem sample ret clu scan 优惠价
某百货公司为了促销,采用购物打折的优惠方法,每位顾客一次购物:在1000元以上者,按9.5折优惠;在2000以上者,按9折优惠;在3000以上者,按8.5折优惠;在5000以上者,按8折优惠;编写程序,购物款数,计算并输出优惠价。
850 1230 5000 3560
discount=1,pay=850 discount=0.95,pay=1168.5 discount=0.8,pay=4000 discount=0.85,pay=3026
#include<stdio.h> int main() { double discount,pay; scanf("%lf",&pay); if(pay-1000<0) { discount=1; printf("discount=%g,pay=%g\n",discount,pay); } else if(pay>=1000&&pay<2000) { discount=0.95; pay=pay*discount; printf("discount=%g,pay=%g\n",discount,pay); } else if(pay>=2000&&pay<3000) { discount=0.9; pay=pay*discount; printf("discount=%g,pay=%g\n",discount,pay); } else if(pay>=3000&&pay<5000) { discount=0.85; pay=pay*discount; printf("discount=%g,pay=%g\n",discount,pay); } else if(pay>=5000) { discount=0.8; pay=pay*discount; printf("discount=%g,pay=%g\n",discount,pay); } return 0; }
标签:disco scanf double problem sample ret clu scan 优惠价
原文地址:https://www.cnblogs.com/Lazy-Cat/p/9838154.html