#include<stdio.h>
float tizhi(float height,float weight);
void JudgeBodyIndex(float height,float weight);
int main()
{
JudgeBodyIndex();
return 0 ;
}
float tizhi(float height,float weight)
{
float t;
t=weight/height*height;
return t;
}
void JudgeBodyIndex(float height,float weight)
{
float t;
printf("请输入身高:");
scanf("%f",&height);
printf("请输入体重:");
scanf("%f",&weight);
t=tizhi(height,weight);
}
JudgeBodyIndex()函数不需要设置参数
你题目的解答代码如下:
#include <stdio.h>
float tizhi(float height, float weight);
void JudgeBodyIndex();
int main()
{
JudgeBodyIndex();
return 0;
}
float tizhi(float height, float weight)
{
float t;
t = weight / height * height;
return t;
}
void JudgeBodyIndex()
{
float height, weight;
float t;
printf("请输入身高:");
scanf("%f", &height);
printf("请输入体重:");
scanf("%f", &weight);
t = tizhi(height, weight);
printf("%.2f\n",t);
}
如有帮助,望采纳!谢谢!