int main(int argc, char** argv)
{
int amount = 0
scanf("%d", &amount)//输入顾客购买的总额
int status = amount/1000
switch (status)
{
case 0: break
case 1: amount = amount * 0.95break
case 2: amount = amount*0.90break
case 3: amount *= 0.85break
default: amount *= 0.80break
}
printf("%d\n", amount)//打印出打折后的总额
return 0
}
#include <iostream>using namespace std
int main()
{
float price
cout<<"输入原价:"<<endl
cin>>price
switch((int)price/1000)
{
case 5:price *=0.8break
case 4:
case 3:price *=0.85break
case 2:price *=0.9break
case 1:price *=0.95break
case 0:break
default:price *=0.8
}
cout<<"优惠价:"<<price<<endl
return 0
}
#include <stdio.h>int main()
{
float totalprice=0,level=0 //总的消费额,打折等级标志
scanf("%d",&totalprice)
if(totalprice<=1000) level=1 //一共分为五等,不同等级,对应不同的优惠策略。
else if(totalprice>1000 &&totalprice<=2000) level=2
else if(totalprice>2000 &&totalprice<=3000) level=3
else if(totalprice>3000 &&totalprice<=5000) level=4
else level=5
switch(level) //一共分为五等,不同等级,对应不同的优惠策略。
{
case 1: printf("%f",totalprice)break
case 2: printf("%f",totalprice*0.95)break
case 3: printf("%f",totalprice*0.90)break
case 4: printf("%f",totalprice*0.85)break
default: printf("%f",totalprice*0.80)break
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)