看板 FJU-Stat97A 關於我們 聯絡資訊
#include <stdio.h> #include <stdlib.h> /* 今日主題:選擇敘述 (10/22) 497761039 統資二甲 曾國顏 ==為正確的輸入方式.代表 左式判斷為某數 =則表示將右式帶入左式 !=則為不等於 &&且 \\或 else if 為一種最佳的條件敘述寫法,代表一種除此之外的用法 較if使用為佳 --18.5 18.5-24 24-27 27-30 30-35 35++*/ int main(void) { int height; double weight; double bmi; printf("請輸入身高(公分):>\n\n"); scanf("%d",&height); printf("請輸入體重(公斤):>\n\n"); scanf("%lf",&weight); bmi = weight/((height/100.0)*(height/100.0)); printf("你的bmi值是:%f\n\n\n",bmi); if(bmi<18.5) { printf("體重過輕\n\n"); } else if(bmi<24) { printf("恭喜你正常\n\n"); } else if(bmi<27) { printf("過重\n\n"); } else if(bmi<30) { printf("輕度肥胖\n\n"); } else if(bmi<35) { printf("中度肥胖\n\n"); } else { printf("重度肥胖\n\n"); } system("pause"); return(0); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.136.162.155
i4303348:幹麻M 因為是http://tinyurl.com/yllgtny140.136.162.153 10/22 16:14