cout&cin
Q:求BMI
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
float weight;
float height;
cout << "請輸入體重:";
cin >> weight;
cout << "請輸入身高:";
cin >> height;
float bmi = weight / pow(height, 2);
cout << "bmi = " << bmi << " 公斤/平方公尺\n";
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
float weight;
float height;
cout << "請輸入體重:";
cin >> weight;
cout << "請輸入身高:";
cin >> height;
float bmi = weight / pow(height, 2);
cout << "bmi = " << bmi << " 公斤/平方公尺\n";
system("PAUSE");
return EXIT_SUCCESS;
}