项目一:标准体重
#include<iostream>
using namespace std;
int main()
{
double weight,high,bweight;
cout<<"请输入身高和体重:";
cin>>high>>weight;
bweight=high-100;
if(weight>bweight*(1+0.2))
cout<<"超重"<<endl;
else if(weight<bweight*(1+0.2))
cout<<"超轻"<<endl;
else
cout<<"正常"<<endl;
return 0;
}
项目二:分段函数求值
#include<iostream>
using namespace std;
int main()
{
int x,y;
cout<<"请输入整数x的值"<<endl;
cin>>x;
if(x>=1)
y=x-1;
else
y=-x+1;
cout<<"对应y值为"<<y<<'\n';
return 0;
}
项目4:模拟ATM
#include<iostream>
using namespace std;
int main()
{
cout<<"黄氏银行欢迎您"<<endl;
cout<<"请输入密码:"<<endl;
int password;
cin>>password;
if(password==980309)
cout<<"1.查询"<<'\n'<<"2.取款"<<'\n'<<"3.存款"<<'\n'<<"4.转账"<<'\n'<<"0.退出"<<endl;
else
cout<<"密码错误"<<endl;
return 0;
}