Advertisement
realever15

助教作業1-1

Dec 4th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main(){
  4.     int weight;
  5.     double height,bmi;
  6.     printf("請輸入體重(公斤):");
  7.     scanf("%d",&weight);
  8.     printf("請輸入身高(公尺):");
  9.     scanf("%lf",&height);
  10.     bmi=weight/(height*height);
  11.     printf("BMI:%.2lf\n",bmi);
  12.    
  13.     if(bmi<18.5)
  14.     printf("體重過輕\n");
  15.     else if(bmi>=18.5&&bmi<24)
  16.     printf("正常範圍\n");
  17.     else if(bmi>=24)
  18.     printf("體重過重\n");
  19.    
  20.     system("PAUSE");
  21.     return 0;  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement