正在加载图片...
3.1.1if语句 ∥文件名:Ex34cpp #include <iostream. h> 输入购买件数 void main(t count 13 float price=80, discount, amount;/单价、折扣、总价 count<5 discount=1 int count /购买件数 cout<"输入购买件数:"<<end; amount=80*3*1=240 cin>>count 输出购买件数3 if(count<5) discount=1: 单价:80折扣:1 总价:240 else if(count<10) discount=0.9; else discount=0.8; amount=price*count*discount cout<<"购买件数:"<< count<endl cout"单价:"<pie<"折扣:"<ds d: cout<"总价:"<< amounts<endl;} 岗心國3.1.1 if 语句 //文件名:Ex3_4.cpp #include <iostream.h> void main(){ float price=80,discount,amount;//单价、折扣、总价 int count; //购买件数 cout<<"输入购买件数:"<<endl; cin>>count; if(count<5) discount=1; else if(count<10) discount=0.9; else discount=0.8; amount=price*count*discount; cout<<"购买件数:"<<count<<endl; cout<<"单价:"<<price<<'\t'<<"折扣:"<<discount<<endl; cout<<"总价:"<<amount<<endl; } 输入购买件数 count=3 count<5 discount=1 amount=80*3*1=240 输出 购买件数:3 单价:80 折扣:1 总价:240
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有