在這裡插入代碼片
```#include <iostream>
using namespace std;
#include <iomanip>
int main()
{int count = 0;
float faHeight,moHeight,yourHeight;
char gender, likeSport, goodDiet,go;
int flag=1;
while(flag==1)
{
cout<<"Input your gender(m|f|M|F):";
cin>>gender;
cout<<"Input your father's height(cm):";
cin>>faHeight;
cout<<"Input your mother's height(cm):";
cin>>moHeight;
if(gender=='m'||gender=='M')
{
yourHeight=(faHeight+moHeight) * 0.54;
}
else
{
yourHeight= (faHeight*0.923 +moHeight)/2 ;
}
cout<<"Do you like sports?(y|n|Y|N):";
cin>>likeSport;
cout<<"Do you have good diet?(y|n|Y|N):";
cin>>goodDiet;
if((likeSport=='y'||likeSport=='Y')&&(goodDiet=='y'||goodDiet=='Y'))
{
yourHeight=yourHeight*1.035;
}
else if((likeSport=='y')||likeSport=='Y'&&(goodDiet=='n'||goodDiet=='N'))
{
yourHeight=yourHeight*1.02;
}
else if((likeSport=='n'||likeSport=='N')&&(goodDiet=='n'||goodDiet=='N'))
{
yourHeight=yourHeight;
}
else
{
yourHeight=yourHeight*1.015;
}
cout<<"Your Height will be:"<<int(yourHeight)<<endl;
cout<<"Do you want to continue?(y(Y)|n(N)):";
cin>>go;
if(go=='y'||go=='Y')
{
flag=1;
}
else
{
flag=0;
}
}
cout<<"over!"<<endl;
return 0;
}
```cpp
在這裡插入代碼片