SWUST OJ#160
题目描述
某百货公司为了促销,采用购物打折的优惠方法,每位顾客一次购物:在1000元以上者,按9.5折优惠;在2000以上者,按9折优惠;在3000以上者,按8.5折优惠;在5000以上者,按8折优惠;编写程序,购物款数,计算并输出优惠价。
输入
输出
样例输入
样例输出
源代码
#include<stdio.h>
int main()
{
int n;
float discount,pay;
scanf("%d",&n);
if(n<=1000)
discount=1;
pay=n;
if(n>1000 && n<=2000)
{
discount=0.95;
pay=n*discount;
}
if(n>2000 && n<=3000)
{
discount=0.9;
pay=n*discount;
}
if(n>3000 && n<=5000)
{
discount=0.85;
pay=n*discount;
}
if(n>5000)
{
discount=0.8;
pay=n*discount;
}
printf("discount=%g,pay=%g\n",discount,pay);
return 0;
}