正在加载图片...
3.1.1if语句 ∥文件名:Ex34cpp #include <iostream. h> 输入购买件数 void main(t nt= coun float price=80, discount, amount;/单价、折扣、总价 5<count<10 discount=0.9 int count /购买件数 cout<"输入购买件数:"<<end; amount=80*9*0.9=648 cin>>count 输出购买件数:9 if(count5)discount=l 单价:80折扣:0.9 总价:648 else if(count<10) discount=0.9; Ise discount=0.8: amount=price*count*discount cout<<"购买件数:"<< count<endl cout"单价:"<pice"<"折扣:"<dis d: cout<"总价:"<< amounts<endl;} 岗心國3.1.1 if 语句 输入购买件数 count=9 5<count<10 discount=0.9 amount=80*9*0.9=648 输出 购买件数:9 单价:80 折扣:0.9 总价:648 //文件名: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; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有