當前位置:首頁 » 編程軟體 » 編程身高差

編程身高差

發布時間: 2022-02-18 03:57:29

1. c語言編寫程序,按人機對話的形式輸入兩個人的身高,並且計算身高的差

樓主你好
具體代碼如下:
#include<stdio.h>

int main()
{
double height_1,height_2;
double dif;

printf("請輸入兩個人的身高(米/m):");
scanf("%lf%lf",&height_1,&height_2);

dif=height_1-height_2;

if(dif<0)
dif=-dif;
printf("它們的身高差為:%.2fm\n",dif);
}

不懂的可以問我哈
希望能幫助你哈

2. c語言編程,身高預測

#include<stdio.h>

/*

設faHeight為其父身高,moHeight為其母身高,身高預測公式為

男性成人時身高=(faHeight+moHeight)×0.54cm

女性成人時身高=(faHeight×0.923+moHeight)/2cm

此外,如果喜愛體育鍛煉,那麼可增加身高2%;

如果有良好的衛生飲食習慣,那麼可增加身高1.5%。

編程從鍵盤輸入用戶的性別(用字元型變數sex存儲,輸入字元F表示女性,輸入字元M表示男性)、

父母身高(用實型變數存儲,faHeight為其父身高,moHeight為其母身高)、

是否喜愛體育鍛煉(用字元型變數sports存儲,輸入字元Y表示喜愛,輸入字元N表示不喜愛)、

是否有良好的飲食習慣等條件(用字元型變數diet存儲,輸入字元Y表示良好,輸入字元N表示不好),

利用給定公式和身高預測方法對身高進行預測。

*/

voidmain()

{

doublefaHeight=0,moHeight=0,yourHeight=0;

charsex=0,sports=0,diet=0;

printf("輸入你父母的身高:");

scanf("%lf,%lf",&faHeight,&moHeight);

printf("輸入你的性別(F代表女性,M代表男性):");

getchar();

scanf("%c",&sex);

printf("是否喜愛體育鍛煉?Y表示喜愛,N表示不喜愛");

getchar();

scanf("%c",&sports);

printf("是否有良好的飲食習慣?Y表示有,N表示沒有");

getchar();

scanf("%c",&diet);

if(sex=='M')

yourHeight=(faHeight+moHeight)*0.54;

elseif(sex=='F')

yourHeight=(faHeight*0.923+moHeight)/2;

if(sports=='Y')

yourHeight=yourHeight*1.02;

if(diet=='Y')

yourHeight=yourHeight*1.015;

printf("你的身高是:%lf",yourHeight);

}

3. 編程,根據用戶從鍵盤輸入一個成年人的身高和體重,來判斷是否是標准體型.

clear
input "請輸入身高cm" to sg
input "請輸入體重kg" to tz
do case
case sg<150
?"特殊體型"
case tz=sg-150
?"標准"
case tz>sg-150
?"過胖"
case tz<sg-150
?"過瘦"
endcase
return

4. 怎麼用C語言編程實現身高預測

照著這個公式寫應該沒有問題吧?

這個公式能大概預測一下:

歐洲科學家的預測子女身高公式如下:

兒子成年身高(cm)=(父親身高+母親身高)×1.08/2

女兒成年身高(cm)=(父親身高×0.923+母親身高)/2

我國的身高預測公式,比用國外的公式預測誤差小。

身高預測公式如下:(單位:厘米)

男孩身高=59.699+0.419×父親身高+0.265×母親身高

女孩身高=43.089+0.306×父親身高+0.431×母親身高

5. 用C語言編寫程序:輸入體重和身高,輸出體重指數BMI

例子如下:

知識擴展:

BMI指數(即身體質量指數,簡稱體質指數又稱體重,英文為Body Mass Index,簡稱BMI),是用體重公斤數除以身高米數平方得出的數字,是目前國際上常用的衡量人體胖瘦程度以及是否健康的一個標准。主要用於統計用途,當我們需要比較及分析一個人的體重對於不同高度的人所帶來的健康影響時,BMI值是一個中立而可靠的指標。

BMI值原來的設計是一個用於公眾健康研究的統計工具。當我們需要知道肥胖是否對某一疾病的致病原因時,我們可以把病人的身高及體重換算成BMI值,再找出其數值及病發率是否有線性關聯。不過,隨著科技進步,現時BMI值只是一個參考值。要真正量度病人是否肥胖,還需要利用微電力量度病人的阻抗,以推斷病者的脂肪厚度。因此,BMI的角色也慢慢改變,從醫學上的用途,變為一般大眾的纖體指標。

6. 用C語言編程預測身高

就這么點東西還能做畢業設計啊……佩服
懸賞0分,更佩服!

7. 身高測量c語言編程

#include <stdio.h>
void main()
{
char sex;
int f,m;
printf("測量人的性別(m/f):");
scanf("%c",&sex);
switch(sex)
{
case 'm':printf("%g",(1.7+1.6)*1.08/2);break;
case 'f':printf("%g",(1.7+1.6*0.923)/2);break;
default:printf("輸入錯誤!");
}
return;
}

//純手打,望採納,有問題追問

8. C語言編程關於身高預測問題,請大神幫忙看看哪裡錯了急急急急!

#include<stdio.h>
void main()
{
char sex,sports,diet;
float faHeight,moHeight,chHeight = 0;
scanf("%c,%c,%c,%f,%f",&sex,&sports,&diet,&faHeight,&moHeight);
if(sex == 'M')
chHeight = (faHeight + moHeight)*0.54;
else if(sex == 'F')
chHeight = (faHeight*0.923+moHeight)/2;
if(sports == 'Y')
chHeight = chHeight * 1.02;
if(diet == 'Y')
chHeight = chHeight * 1.015;
printf("height = %f",chHeight);

}
手打不容易,你寫的程序稍後給你分析,你先用我這個應急吧~~

9. c語言編程實現根據某人的身高和體重判斷其身體指數

很簡單,只是需要接受兩個鍵盤輸入的值,做一個自定義條件判斷輸出不同狀態。這應該是老師給你的作業,目的還是訓練你自己,我們幫你完成對你沒什麼好處。

// 以下是參考
//一個簡單的標准:身體指數與體重、身高的關系為: 身體指數 t=w/(h*h);其中w為體重,h為身高 當t<18時,偏瘦。 當18<=t<25時,正常體重。 當25<=t<27時,超重。 當t>=27時,肥胖。
int main()
{
int t = 0;
float h = 0.0, w = 0.0;

scanf("請輸入你的體身高(單位:m)和體重(單位:kg):%f%f", &h, &w);
t = w / (h * h);

if (t < 18)
{
printf("偏瘦!");
}
else if (t >= 18 && t <25)
{
printf("正常體重!");
}
else if (t >= 25 && t < 27)
{
printf("超重!");
}
else if (t >= 27)
{
printf("肥胖!");
}

return 0;
}

個性簽名:3011

10. C++編程問題 參賽選手身高問題II

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct node{
int num;
int h1, h2, h3;
int ans;
};

node no[30001];
int arrayn[30001];

void swap(int *a, int *b){
int temp = *a;
*a = *b;
*b = temp;
}

bool cmp1(node a, node b){
if(a.h1 == b.h1) {
if(a.h2 == b.h2) {
return a.h3 < b.h3;
}else {
return a.h2 < b.h2;
}
}else{
return a.h1 < b.h1;
}
}

bool cmp2(node a, node b){
return a.num < b.num;
}

int main(){
int n;
cin >> n;
for(int i = 0; i < n; ++i){
cin >> no[i].num >> no[i].h1 >> no[i].h2 >> no[i].h3;
if(no[i].h1 > no[i].h2) swap(&no[i].h1, &no[i].h2);
if(no[i].h2 > no[i].h3) swap(&no[i].h2, &no[i].h3);
if(no[i].h1 > no[i].h2) swap(&no[i].h1, &no[i].h2);
}
stable_sort(no, no + n, cmp1);
for(int i = 0; i < n; i++){
no[i].ans = i+1;
}
stable_sort(no, no + n, cmp2);
for(int i = 0; i < n; i++){
cout << i+1 << ' ' << "2013hwt" << no[i].ans << endl;
}
return 0;
}

熱點內容
mplayerlinux 發布:2024-04-19 20:33:57 瀏覽:799
華勤伺服器怎麼樣 發布:2024-04-19 20:33:15 瀏覽:409
安卓app應用程序擴展名是什麼 發布:2024-04-19 20:08:29 瀏覽:558
sqlserver2005圖標 發布:2024-04-19 19:37:26 瀏覽:946
動畫與編程 發布:2024-04-19 18:53:10 瀏覽:315
把自己家的wifi加密 發布:2024-04-19 18:47:23 瀏覽:574
顯卡資料庫 發布:2024-04-19 18:47:22 瀏覽:553
iosapp清除緩存 發布:2024-04-19 18:47:18 瀏覽:270
sql應用領域 發布:2024-04-19 18:42:56 瀏覽:37
訪問外網伺服器加速軟體 發布:2024-04-19 17:48:45 瀏覽:696