roberthsu2003 / cAndC-

51 stars 18 forks source link

作業3 #14

Closed roberthsu2003 closed 7 months ago

roberthsu2003 commented 8 months ago

請計算使用者的BMI

請輸入您的身高(公分):xxx
請輸入您的體重(公斤):xxx

您的BMI:xxxx
XOYouLinOX commented 8 months ago
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  double kg ,cm;
  cout << "請輸入您的身高(公分):";
  cin >> cm;
  cout << "請輸入您的體重(公斤):";
  cin >> kg;

  cout << "您的BMI:"<< kg/pow(cm/100,2);
}
lan0223333 commented 8 months ago
#include <iostream>
using namespace std;
int main() {
  double heigth, weight, bmi;
  cout << "輸入身高(公尺)" << endl;
  cin >> heigth;
  cout << "輸入體重" << endl;
  cin >> weight;
  bmi = weight / (heigth / 100 * heigth / 100);
  cout << "你的bmi是" << bmi << endl;
}
qwezxciop46 commented 8 months ago
#include <iostream>
using namespace std;
int main() {
  double in1,in2,max;
  cout << "請輸入您的身高(公分):";
  cin >> in1;

  cout << "請輸入您的體重(公斤):";
  cin >> in2;

  in1/=100;
  max = in2/(in1*in1);
  cout << "您的BMI:" << max << "\n";

  return 0;
}
Rickylo0918 commented 8 months ago
#include <iostream>
using namespace std;

int main() {
  double h, w, BMI;

  cout << "請輸入您的身高(公分):";
  cin >> h;

  cout << "請輸入您的體重(公斤):";
  cin >> w;

  BMI = w / ((h / 100.0) * (h / 100.0));

  cout << "您的BMI為:" << BMI << endl;

  return 0;
}
Ray07046666 commented 8 months ago
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  double a,b,area;
  cout<<"請輸入你的身高(m):";
  cin>>a;
  cout<<"請輸入你的體重(kg):";
  cin>>b;
  area=b/(a*a);
  cout<<"您的BMI值為:"<<area<<endl;

}
alvin951020 commented 8 months ago
#include <iostream>
using namespace std;
int main() {
  double height;
  double weight;
  double bmi;

  cout<<"請輸入您的身高(公分):";
  cin>>height;
  cout<<"請輸入您的體重(公斤):";
  cin>>weight;
  height/=100;
  bmi=weight/(height*height);
  cout<<"您的BMI為:"<<bmi;
}
ChiuKuanHsun commented 8 months ago
#include <iostream>
#include <math.h>
using namespace std;
double BMI(double weight, double height) {
  double result = weight / pow(height, 2);
  return result;
}
int main() {
  double weight,height;
  cout<<"請輸入體重(Kg):";
  cin>>weight;
  cout<<"請輸入身高(m):";
  cin>>height;
  double result=BMI(weight,height);
  cout<<"BMI為:"<<result<<endl;
}