问题及代码:
/*
*Copyright (c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:standard.cpp
*作 者:赵敏
*完成日期:2014年12月22日
*版 本 号:v1.0
*
*问题描述:输入一个人的姓名,性别,身高,体重。输出其体重情况。
*/
#include <iostream>
using namespace std;
struct people
{
char name[20];
char sex;
int weight;
int high;
}peo1;
int main()
{
double s,over;
cin>>peo1.name>>peo1.sex>>peo1.weight>>peo1.high;
if(peo1.sex='m')
s=(peo1.high-80)*0.7;
if(peo1.sex='w')
s=(peo1.high-70)*0.6;
over=(peo1.weight-s)/s;
if(over<=0.1&&over>=-0.1)
cout<<"你的体重是标准体重哦!"<<endl;
if(over>0.1&&over<=0.2)
cout<<"有点过重哦,要注意咯"<<endl;
if(over<-0.1&&over>-0.2)
cout<<"体重过轻"<<endl;
if(over>0.2)
cout<<"肥胖哦,你需要减减啦"<<endl;
if(over<=-0.2)
cout<<"你太轻啦,需要增肥了"<<endl;
return 0;
}
运行结果: