01./*
02.* 程序的版权和版本声明部分:
03.* Copyright (c) 2011, 烟台大学计算机学院
04.* All rights reserved.
05.* 文件名称:test.cpp
06.* 作 者:刘芳
07.* 完成日期:2014 年03 月02 日
08.* 版 本 号:v1.0
09.* 对任务及求解方法的描述部分:
10.* 输入描述:无
11.* 问题描述:
12.* 程序输出:
13.* 问题分析:略
14.* 算法设计:略
15.*/
#include <iostream>
//#include<cstring>
#include<cstdio>
using namespace std;
struct Student
{
char name;
char sex;
double height;
double weight;
};
void Biaozhen(Student);
int main()
{
Student student;
cout<<"请输入学生的姓名,性别(M代表男。W代表女),身高,体重:"<<endl;
cin>>student.name>>student.sex>>student.height>>student.weight;
Biaozhen(student);
return 0;
}
void Biaozhen(Student student)
{
double standard;
if(student.sex=='M')
{
standard=(student.height-80)*0.7;
{
if( standard*0.9>=student.weight&& standard*1.1<=student.weight)
cout<<"恭喜!该同学的体重为正常体重"<<endl;
else if( standard*0.8<=student.weight&&standard*0.9>=student.weight)
cout<<"该同学的体重过轻,请注意饮食"<<endl;
else if(standard*0.8>=student.weight)
cout<<"该同学的体重不足,请注意饮食"<<endl;
else if(standard*1.1<=student.weight&&standard*1.2>=student.weight)
cout<<"该同学的体重过重,请注意饮食"<<endl;
else if(standard*1.2<=student.weight)
cout<<"该同学的体重为肥胖,请注意饮食"<<endl;
}
}else
{
standard=(student.height-70)*0.6;
{
if( standard*0.9>=student.weight&& standard*1.1<=student.weight)
cout<<"恭喜!该同学的体重为正常体重"<<endl;
else if( standard*0.8<=student.weight&&standard*0.9>=student.weight)
cout<<"该同学的体重过轻,请注意饮食"<<endl;
else if(standard*0.8>=student.weight)
cout<<"该同学的体重不足,请注意饮食"<<endl;
else if(standard*1.1<=student.weight&&standard*1.2>=student.weight)
cout<<"该同学的体重过重,请注意饮食"<<endl;
else if(standard*1.2<=student.weight)
cout<<"该同学的体重为肥胖,请注意饮食"<<endl;
}
}
}
多次修改,换用了方法,最后有崩溃的感觉,坚持!!!!!!!!!!!