正在加载图片...
3.1.1if语句 ∥文件名:Ex34cpp #include <iostream. h> 输入购买件数 void main(t count=10 float price=80, discount, amount;/单价、折扣、总价 Count=10 discount=0. 8 int count /购买件数 cout<"输入购买件数:"<<end; amount=80*10=0.8=640 cin>>count 输出购买件数:10 if(count<5 )discount; 单价80折扣:0.8 总价:640 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 语句 输入购买件数 count=10 Count=10 discount=0.8 amount=80*10*0.8=640 输出 购买件数:10 单价:80 折扣:0.8 总价:640 //文件名: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 高等教育资讯网 版权所有