//算孩子身高
#include<stdio.h>
#define HEG 0.54
float height(float father, float mother);
int 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;
}
float height(float father, float mother)
{
float son =(mother + father)*HEG;
return 0;
}
那个函数返回值改一下就行了。
//算孩子身高
#include<stdio.h>
#define HEG 0.54
float height(float father, float mother);
int main()
{
float father;
float mother;
float son;
printf("请输入父亲的身高:\n");
scanf("%f", &father);
printf("请输入母亲的身高\n");
scanf("%f", &mother);
son = height(father, mother);
printf("预测孩子的身高:");
printf("%.2f\n",son);
return 0;
}
float height(float father, float mother)
{
float son =(mother + father)*HEG;
return son;
}
第28行:return 0; 改为: return son;
1.创建和打印游戏菜单
2.创建两个棋盘数组,一个是布置雷的棋盘数组,一个是排查雷的棋盘数组
3.初始化两个棋盘,为了防止后期统计排查雷的个数出现矛盾,所以我这里把布置雷的那个棋盘全部初始为'0',把排查雷的棋盘全部初始化为'*'
4.打印棋盘
5.布置雷,由电脑自主完成随机布置雷的个数,个数可以自己在头文件中定义
6.排查雷,在布置雷的数组里排查,如果是雷则打印被炸死,并退出游戏,打印排查雷的棋盘;如果不是雷,则统计雷的个数,是0则展开空白,不是0则将雷的个数传给排查雷的那个数组
7.判断输赢,如果空格的总的个数于行和列的乘积减去布雷的个数,则表示排雷成功