C语言关于身高的

来源:百度知道 编辑:UC知道 时间:2024/07/05 05:02:32
Main()
{
Float sex woman man faheight moheight;
Char sport diet;
Scanf (“%d%f%f%c%c”,&sex,&faheight,&moheight,&sport,&diet);
Printf(“输入1表示女性0表示男性,父亲身高,母亲身高,是否喜欢运动(Y/N),是否有良好饮食习惯(Y/N)”);
If (sex=0,sport=N,diet=N)
man=(faheight+moheight)*0.54;
printf(“man=%f”,man);
else if(sex=0,sport=Y,diet=N)
man=((faheight+moheight)*0.54)*(1+2%);
printf(“man=%f”,man);
else if(sex=0,sport=Y,diet=Y)
man=((faheight+moheight)*0.54)*(1+2%)*(1+1.5%)
printf(“man=%f”,man);
if(sex=1,sport=N,diet=N)
woman=(faheight+0.923+moheight)/2;
printf(“woman=%f”,woman);
else if (sex=1,sport=Y,diet=N)
woman=((faheight+0.923+moheight)/2)*(1+2%);
printf(“woman=%f”,woman);
else if (sex=1,sport=Y,diet=Y)
woman=((faheight+0.923+moheight)/2)*(1+2%)*(1+1.5%);
printf(“woman=%f”,woman);
}

#include”stdio.h”
Main()
{

你这个是两个程序吧,问题很多啊,你看下我改的吧。

第一个程序:
#include <stdio.h>

int main() {
float sex, woman, man, faheight, moheight;
char sport, diet;
scanf (" %d %f %f %c %c", &sex, &faheight, &moheight, &sport, &diet);
printf("输入1表示女性0表示男性,父亲身高,母亲身高, 是否喜欢运动(Y / N), 是否有良好饮食习惯(Y / N)");
if (sex == 0, sport == 'N', diet == 'N') {
man = (faheight + moheight) * 0.54;
printf("man = % f", man);
} else if (sex == 0, sport == 'Y', diet == 'N') {
man = ((faheight + moheight) * 0.54) * (1 + 2. / 100);
printf("man = % f", man);
} else if (sex == 0, sport == 'Y', diet == 'Y') {
man = ((faheight + moheight) * 0.54) * (1 + 2. / 100) * (1 + 1.5 / 100);
printf("man = % f", man);
}
if (sex == 1, sport == 'N', diet == 'N') {
woman = (faheight + 0.923 + moheight) / 2;