c语言的问题,麻烦大神解决一下,谢谢 5
#include<stdio.h>intmain(){charsex,F,M,Y,N,sports,diet;doublefaHeight,moHeight,h,h1=0...
#include <stdio.h>
int main()
{
char sex, F,M,Y,N,sports, diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%*c%*C",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%*c%*C",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%*c%*C",&diet);
if (sex == 'F')
{ if(sports==Y)
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.035;
}
else
{h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf",h);
}
}
else
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.015;
}
else
{h= (0.923*h1+h2)/2;
printf("我的身高:%lf",h);
}
}
}
else
{ if(sports==Y)
{if(diet==Y)
{h=(h1+h2)*0.54*1.035;
}
else
{h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf",h);
}
}
else
{ if(diet==Y)
{h=(h1+h2)*0.54*1.015;
}
else
{h=(h1+h2)*0.54;
printf("我的身高:%lf",h);
}
}
}
} 展开
int main()
{
char sex, F,M,Y,N,sports, diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%*c%*C",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%*c%*C",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%*c%*C",&diet);
if (sex == 'F')
{ if(sports==Y)
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.035;
}
else
{h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf",h);
}
}
else
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.015;
}
else
{h= (0.923*h1+h2)/2;
printf("我的身高:%lf",h);
}
}
}
else
{ if(sports==Y)
{if(diet==Y)
{h=(h1+h2)*0.54*1.035;
}
else
{h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf",h);
}
}
else
{ if(diet==Y)
{h=(h1+h2)*0.54*1.015;
}
else
{h=(h1+h2)*0.54;
printf("我的身高:%lf",h);
}
}
}
} 展开
2个回答
展开全部
#include <stdio.h>
void main()
{
char sex,sports,diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%*c%*C",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%*c%*C",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%*c%*C",&diet);
if (sex=='F')
{
if(sports=='Y')
{
if(diet=='Y')
{
h=(0.923*h1+h2)/2*1.035;
}
else
{
h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf\n",h);
}
}
else
{
if(diet=='Y')
{
h=(0.923*h1+h2)/2*1.015;
}
else
{
h= (0.923*h1+h2)/2;
printf("我的身高:%lf\n",h);
}
}
}
else
{
if(sports=='Y')
{
if(diet=='Y')
{
h=(h1+h2)*0.54*1.035;
}
else
{
h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf\n",h);
}
}
else
{
if(diet=='Y')
{
h=(h1+h2)*0.54*1.015;
}
else
{
h=(h1+h2)*0.54;
printf("我的身高:%lf\n",h);
}
}
}
}
首先 你写的是主函数 主函数没有返回值 所以用void main就行
然后 if里面的字符要加‘’单引号,如果是字符串的话 要加双引号
还有 如果是出现了error C2018: unknown character '0xa1'这样的错误提示,表示错误行输入了全角空格 vc++不识别 所以只要把空格删掉就好了
满意了就给分吧
void main()
{
char sex,sports,diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%*c%*C",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%*c%*C",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%*c%*C",&diet);
if (sex=='F')
{
if(sports=='Y')
{
if(diet=='Y')
{
h=(0.923*h1+h2)/2*1.035;
}
else
{
h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf\n",h);
}
}
else
{
if(diet=='Y')
{
h=(0.923*h1+h2)/2*1.015;
}
else
{
h= (0.923*h1+h2)/2;
printf("我的身高:%lf\n",h);
}
}
}
else
{
if(sports=='Y')
{
if(diet=='Y')
{
h=(h1+h2)*0.54*1.035;
}
else
{
h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf\n",h);
}
}
else
{
if(diet=='Y')
{
h=(h1+h2)*0.54*1.015;
}
else
{
h=(h1+h2)*0.54;
printf("我的身高:%lf\n",h);
}
}
}
}
首先 你写的是主函数 主函数没有返回值 所以用void main就行
然后 if里面的字符要加‘’单引号,如果是字符串的话 要加双引号
还有 如果是出现了error C2018: unknown character '0xa1'这样的错误提示,表示错误行输入了全角空格 vc++不识别 所以只要把空格删掉就好了
满意了就给分吧
展开全部
#include <stdio.h>
int main()
{
char sex, F,M,Y,N,sports, diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%c",&sex);
scanf("%c",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%c",&sports);
scanf("%c",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%c",&diet);
scanf("%c",&diet);
if (sex == 'F')
{ if(sports==Y)
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.035;
}
else
{h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf",h);
}
}
else
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.015;
}
else
{h= (0.923*h1+h2)/2;
printf("我的身高:%lf",h);
}
}
}
else
{ if(sports==Y)
{if(diet==Y)
{h=(h1+h2)*0.54*1.035;
}
else
{h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf",h);
}
}
else
{ if(diet==Y)
{h=(h1+h2)*0.54*1.015;
}
else
{h=(h1+h2)*0.54;
printf("我的身高:%lf",h);
}
}
}
}
int main()
{
char sex, F,M,Y,N,sports, diet;
double faHeight, moHeight, h,h1=0,h2=0;
printf("请输入父亲身高(cm)");
scanf("%lf",&faHeight);
printf("请输入母亲身高(cm)");
scanf("%lf", &moHeight);
h1=faHeight,h2=moHeight;
printf("请输入孩子性别(F:女性,M:男性)");
scanf("%c",&sex);
scanf("%c",&sex);
printf("是否喜爱体育锻炼(Y/N)?");
scanf("%c",&sports);
scanf("%c",&sports);
printf("是否有良好饮食习惯(Y/N)?");
scanf("%c",&diet);
scanf("%c",&diet);
if (sex == 'F')
{ if(sports==Y)
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.035;
}
else
{h= (0.923*h1+h2)/2*1.02;
printf("我的身高:%lf",h);
}
}
else
{if(diet==Y)
{h=(0.923*h1+h2)/2*1.015;
}
else
{h= (0.923*h1+h2)/2;
printf("我的身高:%lf",h);
}
}
}
else
{ if(sports==Y)
{if(diet==Y)
{h=(h1+h2)*0.54*1.035;
}
else
{h= (h1+h2)*0.54*1.02;
printf("我的身高:%lf",h);
}
}
else
{ if(diet==Y)
{h=(h1+h2)*0.54*1.015;
}
else
{h=(h1+h2)*0.54;
printf("我的身高:%lf",h);
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询