1.第二次上机项目1 身高体重
#include <iostream>
using namespace std;
int main()
{
double h,m,M;
cout<<"请输入您的身高体重:";
cin>>h>>m;
M=h-100;
if(m>1.2*M)
cout<<"超重了哦记得锻炼哟:"<<endl;
if(m<1.2*M)
cout<<"超轻不要刻意减肥啦:"<<endl;
else
cout<<"正常范围继续保持哦:"<<endl;
return 0;
}
2.第二次上机项目2分段函数求值
#include <iostream>
using namespace std;
int main()
{
int x,y;
cout<<"请输入x的值:";
cin>>x;
if(x>=1)
y=x-1;
else
y=1-x;
cout<<y<<endl;
return 0;
}
3.第二次上机实验4 模拟ATM
#include <iostream>
using namespace std;
int main()
{
cout<<"曾氏银行欢迎您:"<<endl;
cout<<"请输入您的密码:";
int password;
cin>>password;
if (password==970215)
cout<<"1.查询:"<<'\n'<<"2.取款:"<<'\n'<<"3.存款:"<<'\n'<<"4.转帐:"<<'\n'<<"0.退出:"<<endl;
else
cout<<"您的密码输入错误,请重输:"<<endl;
return 0;
}