02.* Copyright (c) 2013, 烟台大学计算机学院
03.* All rights reserved.
04.* 作 者:石尧
05.* 完成日期:2014 年 2 月 28 日
06.* 版 本 号:v1.0
07.*/
#include <iostream>
#include <string.h>
struct xinxi
{
char name[20];
char sex[8];
int age; \\声明结构体xinxi
double hight;
double weight;
}s;
using namespace std;
void output();
int main()
{
cout<<"请输入姓名:";
cin>>s.name;
cout<<endl;
cout<<"请输入性别:";
cin>>s.sex;
cout<<endl;
cout<<"请输入年龄:";
cin>>s.age;
cout<<endl;
cout<<"请输入身高:";
cin>>s.hight;
cout<<endl;
cout<<"请输入体重:";
cin>>s.weight;
cout<<endl;
cout<<s.name<<endl;
cout<<s.sex<<endl; \\输出结构体内容
cout<<s.age<<endl;
cout<<s.hight<<endl;
cout<<s.weight<<endl;
output();
return 0;
}
void output ()
{
float n; \\用n表示标准体重
if(strcmp(s.sex,"G")==0)
{
n=(s.hight-80)*0.7;
if(s.weight<=(n*1.1)||s.weight>=(n*0.9))
cout<<"您的体重正常!"<<endl;
else if(s.weight>=(n*1.1)&&s.weight<=(n*1.2))
cout<<"您的体重过重,请合理饮食!"<<endl;
else if(s.weight>=(n*0.8)&&s.weight<=(n*0.9))
cout<<"您的体重过轻,请合理饮食!"<<endl;
}
if(strcmp(s.sex,"M")==0)
{
n=(s.hight-70)*0.6;
if(s.weight<=(n*1.1)||s.weight>=(n*0.9))
cout<<"您的体重正常!"<<endl;
else if(s.weight>=(n*1.1)&&s.weight<=(n*1.2))
cout<<"您的体重过重,请合理饮食!"<<endl;
else if(s.weight>=(n*0.8)&&s.weight<=(n*0.9))
cout<<"您的体重过轻,请合理饮食!"<<endl;
}
}
胖子的纠结
最新推荐文章于 2024-09-25 10:36:42 发布