【C熟肉】据父母身高及自己习惯判断身高

【C熟肉】据父母身高及自己习惯判断身高,第1张

【C熟肉】据父母身高及自己习惯判断身高
#include

int main()
{
	int sex, sports, diet;
	double myheight=0, faheight, moheight;
	printf("请输入你的性别(男1/女0)n你父亲的身高n你母亲的身高n是否爱锻炼(是1/不是0)n是否有好的饮食习惯(有1/没有0)n");
	scanf_s("%d%lf%lf%d%d", &sex, &faheight, &moheight, &sports, &diet);

	switch (sex)
	{
	case 1:
	{
		if (sports == 1 && diet == 1)
			myheight = (faheight + moheight) * 0.54 * 1.035;
		if (sports == 1 && diet == 0)
			myheight = (faheight + moheight) * 0.54 * 1.02;
		if (sports == 0 && diet == 1)
			myheight = (faheight + moheight) * 0.54 * 1.015;
		if (sports == 0 && diet == 0)
			myheight = (faheight + moheight) * 0.54;
		printf("你的身高可能是:%5.2f cm", myheight); break;
	}

	case 0:
	{
		if (sports == 1 && diet == 1)
			myheight = (faheight * 0.923 + moheight) / 2 * 1.035;
		if (sports == 1 && diet == 0)
			myheight = (faheight * 0.923 + moheight) / 2 * 1.02;
		if (sports == 0 && diet == 1)
			myheight = (faheight * 0.923 + moheight) / 2 * 1.015;
		if (sports == 0 && diet == 0)
			myheight = (faheight * 0.923 + moheight) / 2;
		printf("你的身高可能是:%5.2f cm", myheight); break;
	}
	}
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5636238.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存