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;
}
}
胖子的糾結
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.