c语言商场收款程序,c语言 如何用switch语句编写一个有关商场购物金额优惠的选择程式...

c语言 如何用switch语句编写一个有关商场购物金额优惠的选择程式以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

13370c75c50829d647f503f2da695133.png

c语言 如何用switch语句编写一个有关商场购物金额优惠的选择程式

#include

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.95; break;

case 2: amount = amount*0.90; break;

case 3: amount *= 0.85; break;

default: amount *= 0.80; break;

}

printf("%d\n", amount);打印出打折后的总额

return 0;

}

编写c语言程式,输入购物款数,计算并输出优惠价。(要求用switch语句编写)

#include

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;

}

如何用c语言编写一个收款程式?

#include

int main(){

float sum=5.0;

int n; 购买数量

printf("输入要购买的数量:");

scanf("%d",&n); 输入购买数量

if((n>5)&&(n<=10)){ 打九折

sum=sum*n*0.9;

}

if((n>10)&&(n<=20)){

sum=sum*n*0.8;

}

if((n>20)&&(n<=50)){

sum=sum*n*0.7;

}

if((n>50)&&(n<=100)){

sum=sum*n*0.6;

}

if(n>100){

sum=sum*n*0.6;

}

printf("收款:%.1f",sum);

printf("\n");

}

如何用C语言编写一个关程序的程式?

基本思路:

1. 用Process32First+Process32Next列举所有程序。

2. 对列举的程序取程式名,比较是不是要关掉的程式。

3. 如是,呼叫TerminateProcess()结束它。

有的程式一启动就不止一个程序,所以即使关掉一个,也继续列举。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值