Visual Studio 2013
#include<stdio.h> //包含头文件
#define HEG 0.54 //定义常亮
float height(float father, float mother); //函数声明
int main() //主函数main
{
float father; //定义浮点型变量,表示父亲的身高
float mother; //定义浮点型变量,表示母亲的身高
float son; //定义浮点型变量,表示儿子的身高
printf("请输入父亲的身高:\n"); //显示提示
scanf_s("%f", &father); //输入父亲的身高
printf("请输入母亲的身高:\n"); //显示提示
scanf_s("%f", &mother); //输入母亲的身高
son = height(father, mother); //调用函数,计算儿子的身高
printf("预测儿子的身高为:"); //显示提示
printf("%.2f\n", son); //输出儿子的身高
return 0; //返回整型0
}
float height(float father, float mother) //定义计算儿子身高的函数
{
float son = (father + mother)*HEG; //具体计算儿子的身高
return son; //返回儿子的身高
}
Caesar卢尚宇 [email protected]
2018年12月27日
一个完整的C程序
猜你喜欢
转载自blog.csdn.net/lu1287580078/article/details/85304533
今日推荐
周排行