#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;
}
温馨提示:答案为网友推荐,仅供参考