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


41 則留言:

b10533011 江道逸 提到...

#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;

}

B10533062 洪尚郁 提到...

#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;
}

b10533011 江道逸 提到...

#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;

}

B10533015陳建志 提到...

#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;
}

b10533004 李登恩 提到...

#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;
}

B10533006 劉純賓 提到...

#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;
}

B10533009 張仲崴 提到...

#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;
}

B10533062 洪尚郁 提到...

#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;
}

b10533007 魏辰熾 提到...

#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;

}

b10533011 江道逸 提到...

#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;

}

B10533008 張士晟 提到...

#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;
}

B10533010蕭凱維 提到...

#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;
}

b10433081巫明芬 提到...

#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;
}

B10433102楊婷妤 提到...

#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;
}

B10433107袁婕寧 提到...

#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;
}

B10433072廖翊翔 提到...

#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;
}

B10433090 蔡語鋐 提到...

#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;
}

B10433106簡瑋佑 提到...

#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;
}

B10433065劉勝威 提到...

#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;
}

B10433065劉勝威 提到...

#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;
}

B10433099 駱婉婷 提到...

#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;

}

B10433073何明宗 提到...

#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;
}

B10433102楊婷妤 提到...

#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;
}

B10433107袁婕寧 提到...

#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;
}

b10333093 徐子軒 提到...

#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;
}

B10433071雷昕翰 提到...

#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;
}

B10433094 簡筱芸 提到...

#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;
}

B10533132許敏茹 提到...

#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;
}

b10433088葉凱文 提到...

#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;
}

B10533083徐士興 提到...

#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;
}

B10533088葉俊江 提到...

#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;
}

B10537208楊蕊筑 提到...

#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;
}

B10533076 姜國傑 提到...

#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;
}

B10533064蔡佩芸 提到...

#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;
}

B10533029游淑娥 提到...

#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;
}

B10533073黃叡哲 提到...

#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;
}

B10433090蔡語鋐 提到...

#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;
}

b10533075 陳詔瑋 提到...

#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;

}

b10533029 游淑娥 提到...

#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;

}

B10533093許永炎 提到...

#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;

}

Related Posts Plugin for WordPress, Blogger...

熱門文章