網頁

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 則留言:

  1. b10533011 江道逸2017年10月25日 下午2:34

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

    }

    回覆刪除
  2. B10533062 洪尚郁2017年10月25日 下午2:35

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

    回覆刪除
  3. b10533011 江道逸2017年10月25日 下午2:35

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

    }

    回覆刪除
  4. #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;
    }

    回覆刪除
  5. b10533004 李登恩2017年10月25日 下午2:38

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

    回覆刪除
  6. B10533006 劉純賓2017年10月25日 下午2:40

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

    回覆刪除
  7. B10533009 張仲崴2017年10月25日 下午2:44

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

    回覆刪除
  8. B10533062 洪尚郁2017年10月25日 下午2:44

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

    回覆刪除
  9. b10533007 魏辰熾2017年10月25日 下午2:45

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

    }

    回覆刪除
  10. b10533011 江道逸2017年10月25日 下午2:45

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

    }

    回覆刪除
  11. B10533008 張士晟2017年10月25日 下午2:45

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

    回覆刪除
  12. #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;
    }

    回覆刪除
  13. #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;
    }

    回覆刪除
  14. #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;
    }

    回覆刪除
  15. #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;
    }

    回覆刪除
  16. #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;
    }

    回覆刪除
  17. B10433090 蔡語鋐2017年10月25日 下午2:49

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

    回覆刪除
  18. #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;
    }

    回覆刪除
  19. #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;
    }

    回覆刪除
  20. #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;
    }

    回覆刪除
  21. B10433099 駱婉婷2017年10月25日 下午2:53

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

    }

    回覆刪除
  22. #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;
    }

    回覆刪除
  23. #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;
    }

    回覆刪除
  24. #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;
    }

    回覆刪除
  25. #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;
    }

    回覆刪除
  26. b10333093 徐子軒2017年10月25日 下午3:22

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

    回覆刪除
  27. #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;
    }

    回覆刪除
  28. B10433094 簡筱芸2017年10月25日 下午3:43

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

    回覆刪除
  29. #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;
    }

    回覆刪除
  30. #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;
    }

    回覆刪除
  31. #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;
    }

    回覆刪除
  32. #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;
    }

    回覆刪除
  33. #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;
    }

    回覆刪除
  34. B10533076 姜國傑2017年11月1日 凌晨4:17

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

    回覆刪除
  35. B10533064蔡佩芸2017年11月1日 下午1:51

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

    回覆刪除
  36. B10533029游淑娥2017年11月1日 下午1:55

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

    回覆刪除
  37. B10533073黃叡哲2017年11月1日 下午2:07

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

    回覆刪除
  38. B10433090蔡語鋐2017年11月1日 下午4:17

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

    回覆刪除
  39. b10533075 陳詔瑋2017年12月27日 下午3:09

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

    }

    回覆刪除
  40. b10533029 游淑娥2017年12月27日 下午3:09

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

    }

    回覆刪除
  41. B10533093許永炎2018年1月3日 下午2:42

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

    }

    回覆刪除

HTML 編輯器