//使用结构体表示人的相关信息
//数组和类都是一种自定义的数据类型,和int,double用法一样
#include <iostream>
using namespace std;
struct Person
{
char name[20];//定义namechar数组,用于放置人名信息
char sex;//F-女,M-男--性别char数组
double height;
double weight;
};//结构体后要有分号
int main()
{
double st,over;//标准体重,超重比例
Person p;//定义一个Person类型的变量p,p包含Person结构体的全部信息
cin>>p.name/*访问结构体的某项的格式*/>>p.sex>>p.height>>p.weight;
if(p.sex=='F'||p.sex=='f')
st=(p.height-70)*0.6;
else
st=(p.height-80)*0.7;
over=(p.weight-st)/st;
if(over>0.2)
cout<<"您达到了超级那个"<<endl;
else if(over>0.1)
cout<<"还是有些重了"<<endl;
else if(over>-0.1)
cout<<"灰常好,您让人羡慕"<<endl;
else if(over>-0.2)
cout<<"再能重点就更好了"<<endl;
else
cout<<"太轻了,注意营养啊"<<endl;
return 0;
}
07-04
07-05
07-05
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交