要求使用结构体类型表示人的相关信息。
#include<iostream> using namespace std; struct Person { char name[20]; char sex; double height; double weight; }; int main() { double st, over; Person p; cout<<"请输入您的姓名: "; cin>>p.name; cout<<"请输入您的性别(F/M): "; cin>>p.sex; cout<<"请输入您的升高(cm): "; cin>>p.height; cout<<"请输入您的体重(kg): "; cin>>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<<"( ⊙ o ⊙ )啊!!!你身材真好!羡慕%>_<%"<<endl; else if (over>-0.2) cout<<"得多吃点啊!"<<endl; else cout<<"你这样。。。。风都能把你吹倒啊!赶紧多吃点长胖吧!"<<endl; return 0; }
原文地址:http://blog.csdn.net/i__am__legend/article/details/42059447