C++编程(超级基础问题)

来源:百度知道 编辑:UC知道 时间:2024/05/23 21:28:25
1.某百货公司为了促销,采用购物打折的办法。
(1) 在1000元以上者,按九五折优惠;
(2) 在2000元以上者,按九折优惠;
(3) 在3000元以上者,按八五折优惠;
(4) 在4000元以上者,按八折优惠。
编写程序,输入购物款数,计算并输出优惠价。
2.根据输入月,判断该月的天数(2月为28天)
这是2个题 呵呵。。

1.#include<iostream>
using namespace std;
void main()
{
double sh,ho;
cout<<"请输入购物的款数:"<<endl;
cin>>sh;
if(sh>4000) ho=0.8*sh;
else if(sh>3000) ho=0.85*sh;
else if(sh>2000) ho=0.9*sh;
else if(sh>1000) ho=0.95*sh;
else ho=sh;
cout<<ho<<endl;
}
2.#include<iostream>
using namespace std;
void main()
{
int month;
cout<<"请输入月份:"<<endl;
cin>>month;
cout<<"该月的天数为:";
if(month==1||month==3||month==5||month==7||month==8||month==10
||month==12) cout<<"31"<<endl;
else if(month=2) cout<<"28"<<endl;
else cout<<"30"<<endl;
}

//1题
#include<iostream>
using namespace std;
int main()
{
int pr