herrDeng網內搜尋
自訂搜尋
Ads
2017年10月25日 星期三
ex5 C++請用常態分佈或student t分佈亂數產生20筆身高、體重,並計算bmi
請用常態分佈亂數產生20筆身高、體重,並計算bmi
提示:
mt19937 RV(time(0));
normal_distribution<double> X(175, 7);
double height[20];
for(int i=0; i<20; i++)
{
height[i]=X(RV);
.....
常用的機率分佈:
uniform_int_distribution
uniform_real_distribution
bernoulli_distribution
binomial_distribution
poisson_distribution
student_t_distribution
訂閱:
張貼留言 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
python pandas對黃金、外匯匯率的爬蟲練習,並使用matplotlib.pyplot的函數plot, scatter做資料視覺化處理,採用numpy的統計函數,分析黃金價格波動與歐元走勢的關聯。
-
Python C C++ 2 pointer速解Leetcode 2337 Move Pieces to Obtain a String 多日Leetcode的問題都可用2-pointer法來解,今日2337. Move Pieces to Obtain a String也不例...
-
你會用C的算子sizeof?
41 則留言:
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main() {
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> X(166, 6.5);
normal_distribution<double> Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> X(176,7.5);
double height[20];
for (int i = 0; i < 100; i++) {
height[i] = X(RV);
cout << i << "--->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> X(175, 7.5);
normal_distribution<double> Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
weight[i] = Y(RV);
cout << i << "---->" << height[i] << endl;
cout << i << "---->" << weight[i] << endl;
}
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h * h)));
}
int main()
{
double h = 160, w = 50;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double>X(160, 6.5);
normal_distribution<double>Y(50, 6.5);
double height[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
cout << i << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h * h)));
}
int main()
{
double h = 170, w = 63;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double>X(170, 6.5);
normal_distribution<double>Y(63, 6.5);
double height[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
cout << i << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main() {
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> X(166, 6.5);
normal_distribution<double> Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
cout << bmi(height[i], weight[i]);
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h * h)));
}
int main()
{
double h = 175, w = 70;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double>X(175, 6.5);
normal_distribution<double>Y(70, 6.5);
double height[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
cout << i << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h * h)));
}
int main()
{
double h = 177, w = 85;
cout << bmi (h, w) << "\n";
mt19937_64 RV(time ( 0 ) );
normal_distribution X (176, 7.5);
double height [100];
for (int i = 0; i < 100; i++) {
height [ i ] = X (RV) ;
cout << i << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w)
{
return (10000 * (w / (h*h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double>X(176, 7.5);
normal_distribution<double>Y(70,5);
for (int i = 0; i < 20; i++)
{
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "---->" << x[i] << endl;
cout << i << "---->" << z[i] << endl;
cout << bmi(x[i],z[i]) <<"\n";
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h * h)));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distributionX(176, 7.5);
double height[100];
for (int i = 0;i<100;i++){
height[i] = X(RV);
cout << 1 << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
double h = 154,w = 45;
cout << bmi(h,w)<< "\n";
mt19937_64 RV (time(0));
normal_distribution X(166, 6.5);
double height[20];
for (int i = 0; i < 20; i++){
height[i] = X(RV);
cout << i << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w)
{
return (10000 * (w / (h * h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double> X(176, 7.5);
normal_distribution<double> Y(70, 5);
for (int i = 0; i < 20; i++) {
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "----->" << "身高=" << x[i] << endl;
cout << i << "----->" << "體重=" << z[i] << endl;
cout << "BMI=" << bmi(x[i], z[i]) << "\n";
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include<ctime>
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
double h = 178, w = 68;
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++)
{
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << endl;
cout << i << "---->" << weight[i] << endl;
cout << bmi(h, w) << "\n";
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
double h = 180, w = 89;
mt19937_64 RV(time(0));
normal_distribution<double> x(166, 6.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << endl;
cout << i << "---->" << weight[i] << endl;
cout << bmi(h, w) << "\n";
}
system("pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<iomanip>
//#include<iomanip> 使用 cout << fixed << setprecision(輸出位數) << 變數/數字 << endl;
//修飾顯示
using namespace std;
double BMI(double h, double w) {
return 10000 * w / (h*h);
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double> X(176, 7.5);
normal_distribution<double> Y(72, 4);
double height[100];
double weight[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
weight[i] = Y(RV);
cout << i <<" 的身高="<< fixed << setprecision (3)<<height[i]
<<"\t體重=" << fixed << setprecision(3) << weight[i]
<<"\tBMI=" << fixed << setprecision(3)<< BMI(height[i], weight[i]) << endl;
}
system("PAUSE");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<iomanip>
//#include<iomanip> 使用 cout << fixed << setprecision(輸出位數) << 變數/數字 << endl;
//修飾顯示
using namespace std;
double BMI(double h, double w) {
return 10000 * w / (h*h);
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double> X(176, 7.5);
normal_distribution<double> Y(72, 4);
double height[100];
double weight[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
weight[i] = Y(RV);
cout << i <<" 的身高="<< fixed << setprecision (3)<<height[i]
<<"\t體重=" << fixed << setprecision(3) << weight[i]
<<"\tBMI=" << fixed << setprecision(3)<< BMI(height[i], weight[i]) << endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
double BMI(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double >x(166, 6.5);
normal_distribution<double >y(72, 4);
double height[100];
double weight[100];
for (int i= 0; i < 20; i++)
{
height[i]=x(RV);
weight[i] =y(RV);
cout << i << "身高" << height[i] <<"體重"<<weight[i]<< "(BMI)"<< BMI(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h * h)));
}
int main()
{
double h = 175, w = 85;
mt19937_64 RV(time(0));
normal_distribution<double> x(166, 6.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++)
{
height[i] = x(RV);
height[i] = y(RV);
cout << i << "---->" << height[i] << endl;
cout << i << "---->" << weight[i] << endl;
cout << i << bmi(h, w) << "\n";
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double> X (176, 7.5);
normal_distribution<double> Y(70, 5);
for (int i = 0; i < 20; i++)
{
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "---->" << x[i] << endl;
cout << i << "---->" << z[i] << endl;
cout << bmi(x[i], z[i]) << "\n";
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w)
{
return(10000 * (w / (h * h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distributionX(176, 7.5);
normal_distributionY(70, 5);
for (int i = 0 ; i<20; i++){
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "---->" << x[i] << endl;
cout << i << "---->" << z[i] << endl;
cout << bmi(x[i], z[i]) << "\n";
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
double h = 154,w = 45;
cout << bmi(h,w)<< "\n";
mt19937_64 RV (time(0));
normal_distribution X(166, 6.5);
normal_distribution Y(60,5);
for (int i = 0; i < 20; i++){
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "---->" <<"身高="<< x[i] << endl;
cout << i << "---->" << "體重=" <<z[i] << endl;
cout << "BMI="<< bmi(x[i],z[i])<<"\n";
}
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
mt19937 RV(time(0));
normal_distribution X(175, 7);
normal_distribution Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
weight[i] = Y(RV);
double tmp = bmi(height[i], weight[i]);
cout <<"身高="<< height[i] << "\t體重= " << weight[i] << "\tbmi= " << tmp << "\n";
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w)
{
return (10000 * (w / (h * h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution X(176, 7.5);
normal_distribution Y(70, 5);
for (int i = 0; i < 20; i++) {
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "----->" << "身高=" << x[i] << endl;
cout << i << "----->" << "體重=" << z[i] << endl;
cout << "BMI=" << bmi(x[i], z[i]) << "\n";
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
double x[20];
double z[20];
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution<double> X (176, 7.5);
normal_distribution<double> Y(70, 5);
for (int i = 0; i < 20; i++)
{
x[i] = X(RV);
z[i] = Y(RV);
cout << i << "---->" << x[i] << endl;
cout << i << "---->" << z[i] << endl;
cout << bmi(x[i], z[i]) << "\n";
}
system("Pause");
return 0;
}
#include <iostream>
#include <ctdlib>
#include<random>
#include<ctime>>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution<double> X(166, 6.5);
normal_distribution<double> Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h * h)));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distributionX(176, 7.5);
double height[100];
for (int i = 0;i<100;i++){
height[i] = X(RV);
cout << 1 << "---->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(166, 6.5);
normal_distribution Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include
#include
#include
#include>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(166, 6.5);
normal_distribution Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include
#include
#include
#include>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(166, 6.5);
normal_distribution Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include
#include
#include
#include
#include
//#include 使用 cout << fixed << setprecision(輸出位數) << 變數/數字 << endl;
//修飾顯示
using namespace std;
double BMI(double h, double w) {
return 10000 * w / (h*h);
}
int main()
{
mt19937_64 RV(time(0));
normal_distribution X(176, 7.5);
normal_distribution Y(72, 4);
double height[100];
double weight[100];
for (int i = 0; i < 20; i++) {
height[i] = X(RV);
weight[i] = Y(RV);
cout << i <<" 的身高="<< fixed << setprecision (3)<<height[i]
<<"\t體重=" << fixed << setprecision(3) << weight[i]
<<"\tBMI=" << fixed << setprecision(3)<< BMI(height[i], weight[i]) << endl;
}
system("PAUSE");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(176,7.5);
double height[20];
for (int i = 0; i < 100; i++) {
height[i] = X(RV);
cout << i << "--->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
int main()
{
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(176,7.5);
double height[20];
for (int i = 0; i < 100; i++) {
height[i] = X(RV);
cout << i << "--->" << height[i] << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include>
using namespace std;
double bmi(double h, double w) {
return 10000 * (w / (h*h));
}
double h = 177, w = 85;
cout << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution X(166, 6.5);
normal_distribution Y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20;i++) {
height[i] = X(RV);
weight[i] = X(RV);
cout << i << "height--->" << height[i] << endl;
cout << i << "weight--->" << weight[i] << endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <random>
#include<ctime>
#include<string>
#include<fstream>
using namespace std;
double bmi(double h, double w) {
return (10000 * (w / (h*h)));
}
int main()
{
double h = 178, w = 68;
mt19937_64 RV(time(0));
normal_distribution<double> x(176, 7.5);
normal_distribution<double> y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++)
{
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << endl;
cout << i << "---->" << weight[i] << endl;
cout << bmi(height[i], weight[i]) << "\n";
fstream fout;
fout.open("i.csv", ios::app);
fout << "身高=," << height[i] << ","
<< "體重=," << weight[i] << ","
<< "BMI=," << bmi(height[i], weight[i]) << "\n";
fout.close();
fstream fin("i.txt", ios::in);
string x;
getline(fin, x);
cout << x << endl;
fin.close();
}
system("pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution x(176, 7.5);
normal_distribution y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution x(176, 7.5);
normal_distribution y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
double bmi(double h, double w) {
return(10000 * (w / (h*h)));
}
int main()
{
double h = 177, w = 85;
cout << h << "/" << w << "=" << bmi(h, w) << "\n";
mt19937_64 RV(time(0));
normal_distribution x(176, 7.5);
normal_distribution y(72, 4);
double height[20];
double weight[20];
for (int i = 0; i < 20; i++) {
height[i] = x(RV);
weight[i] = y(RV);
cout << i << "---->" << height[i] << "/" << weight[i] << "=" << bmi(height[i], weight[i]) << endl;
}
system("Pause");
return 0;
}
張貼留言