

以下に示すプログラムは、100回のスループット率、実加工数、仕掛け品数を出力するものです。

つまり、やりたいことは下記の出力結果の「Through put
ratio」を全て足して、それを100で割るということですが、どのようにプログラムをすれば期待している出力になるのでしょうか。  
お願いします。

**ソースコード:**

[code]

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #include <time.h>
    
    //機械の構造体の用意
    struct machine_type{
      int temochi,kano_kako_su,jitsu_kako_su,kimatsu_zaiko;
    };
    /* ============================================ */
    /*   グローバル変数宣言部                       */
    /* ============================================ */
    struct machine_type mA,mB,mC;
    int i,M,Run;
    int total_jitsu_kako_su,total_shikake;
    int j;
    
    void machine_A(void);
    void machine_B(void);
    void machine_C(void);
    void ABC(void);
    
    void main()
    {
        //乱数の初期化
        srand((unsigned) time(NULL));
        Run=100;
        for(j=0;j<Run;j++){
            printf("%d\t",j);
            ABC();
        }
    }
    
    /* 50期分のシミュレーション */
    void ABC(void)
    {
        //機械の在庫の初期化
        mA.kimatsu_zaiko=0;
        mB.kimatsu_zaiko=0;
        mC.kimatsu_zaiko=0;
    
        //集計用の変数初期化
        total_jitsu_kako_su=0;
        total_shikake=0;
    
        //50期の計算
        for(i=1;i<=50;i++){
            machine_A();        
            if(i>=2){
                machine_B();
            }
            if(i>=3){
                machine_C();
            }
        }
        //期末在庫と仕掛品数の集計
        //実加工数合計と仕掛品数を画面に表示する．
        //スループットを計算して画面に表示する．
        total_shikake=mA.kimatsu_zaiko+mB.kimatsu_zaiko+mC.kimatsu_zaiko;
        printf("Total_jitsu_kako_su =%d\n Total_shikake =%d\n Through put ratio =%lf\n",total_jitsu_kako_su,total_shikake,(double)total_jitsu_kako_su/150);
    }
    
    /* machine_A */
    void machine_A(){
        double r;
    
        mA.temochi=mA.kimatsu_zaiko+3;
    
        r=rand()/(double)RAND_MAX;//[0,1)乱数
        if(r<0.2){
            mA.kano_kako_su=0;
        }
        if(0.2<=r&&r<0.4){
            mA.kano_kako_su=1;
        }
        if(0.4<=r){
            mA.kano_kako_su=5;
        }
    
        if(mA.temochi<=mA.kano_kako_su){
            mA.jitsu_kako_su=mA.temochi;
        }else{
            mA.jitsu_kako_su=mA.kano_kako_su;
        }
        mA.kimatsu_zaiko=mA.temochi-mA.jitsu_kako_su;
    }
    /* machine_B */
    void machine_B(){
        double r;
    
        mB.temochi=mB.kimatsu_zaiko+mA.jitsu_kako_su;
    
        r=rand()/(double)RAND_MAX;//[0,1)乱数
        if(r<0.2){
            mB.kano_kako_su=0;
        }
        if(0.2<=r&&r<0.4){
            mB.kano_kako_su=1;
        }
        if(0.4<=r){
            mB.kano_kako_su=5;
        }
    
        if(mB.temochi<=mB.kano_kako_su){
            mB.jitsu_kako_su=mB.temochi;
        }else{
            mB.jitsu_kako_su=mB.kano_kako_su;
        }
        mB.kimatsu_zaiko=mB.temochi-mB.jitsu_kako_su;
    }
    /* machine_C */
    void machine_C(){
        double r;
    
        mC.temochi=mC.kimatsu_zaiko+mB.jitsu_kako_su;
    
        r=rand()/(double)RAND_MAX;//[0,1)乱数
        if(r<0.2){
            mC.kano_kako_su=0;
        }
        if(0.2<=r&&r<0.4){
            mC.kano_kako_su=1;
        }
        if(0.4<=r){
            mC.kano_kako_su=5;
        }
    
        if(mC.temochi<=mC.kano_kako_su){
            mC.jitsu_kako_su=mC.temochi;
        }else{
            mC.jitsu_kako_su=mC.kano_kako_su;
        }
        mC.kimatsu_zaiko=mC.temochi-mC.jitsu_kako_su;
        //実加工数合計の集計
        total_jitsu_kako_su=total_jitsu_kako_su+mC.jitsu_kako_su;
    }
    
[/code]

**実行結果:**

[code]

    $ ./a.out
    0   Total_jitsu_kako_su =97
     Total_shikake =47
     Through put ratio =0.646667
    1   Total_jitsu_kako_su =120
     Total_shikake =27
     Through put ratio =0.800000
    2   Total_jitsu_kako_su =117
     Total_shikake =28
     Through put ratio =0.780000
    3   Total_jitsu_kako_su =124
     Total_shikake =25
     Through put ratio =0.826667
    4   Total_jitsu_kako_su =114
     Total_shikake =30
     Through put ratio =0.760000
    5   Total_jitsu_kako_su =135
     Total_shikake =9
     Through put ratio =0.900000
    6   Total_jitsu_kako_su =131
     Total_shikake =13
     Through put ratio =0.873333
    7   Total_jitsu_kako_su =112
     Total_shikake =35
     Through put ratio =0.746667
    8   Total_jitsu_kako_su =122
     Total_shikake =22
     Through put ratio =0.813333
    9   Total_jitsu_kako_su =126
     Total_shikake =20
     Through put ratio =0.840000
    10  Total_jitsu_kako_su =120
     Total_shikake =30
     Through put ratio =0.800000
    11  Total_jitsu_kako_su =135
     Total_shikake =12
     Through put ratio =0.900000
    12  Total_jitsu_kako_su =126
     Total_shikake =18
     Through put ratio =0.840000
    13  Total_jitsu_kako_su =126
     Total_shikake =18
     Through put ratio =0.840000
    14  Total_jitsu_kako_su =125
     Total_shikake =23
     Through put ratio =0.833333
    15  Total_jitsu_kako_su =134
     Total_shikake =10
     Through put ratio =0.893333
    16  Total_jitsu_kako_su =127
     Total_shikake =22
     Through put ratio =0.846667
    17  Total_jitsu_kako_su =114
     Total_shikake =30
     Through put ratio =0.760000
    18  Total_jitsu_kako_su =126
     Total_shikake =19
     Through put ratio =0.840000
    19  Total_jitsu_kako_su =120
     Total_shikake =24
     Through put ratio =0.800000
    20  Total_jitsu_kako_su =132
     Total_shikake =12
     Through put ratio =0.880000
    21  Total_jitsu_kako_su =138
     Total_shikake =6
     Through put ratio =0.920000
    22  Total_jitsu_kako_su =119
     Total_shikake =28
     Through put ratio =0.793333
    23  Total_jitsu_kako_su =108
     Total_shikake =38
     Through put ratio =0.720000
    24  Total_jitsu_kako_su =120
     Total_shikake =27
     Through put ratio =0.800000
    25  Total_jitsu_kako_su =139
     Total_shikake =9
     Through put ratio =0.926667
    26  Total_jitsu_kako_su =138
     Total_shikake =11
     Through put ratio =0.920000
    27  Total_jitsu_kako_su =137
     Total_shikake =9
     Through put ratio =0.913333
    28  Total_jitsu_kako_su =108
     Total_shikake =38
     Through put ratio =0.720000
    29  Total_jitsu_kako_su =128
     Total_shikake =20
     Through put ratio =0.853333
    30  Total_jitsu_kako_su =95
     Total_shikake =52
     Through put ratio =0.633333
    31  Total_jitsu_kako_su =125
     Total_shikake =24
     Through put ratio =0.833333
    32  Total_jitsu_kako_su =130
     Total_shikake =17
     Through put ratio =0.866667
    33  Total_jitsu_kako_su =139
     Total_shikake =11
     Through put ratio =0.926667
    34  Total_jitsu_kako_su =131
     Total_shikake =16
     Through put ratio =0.873333
    35  Total_jitsu_kako_su =127
     Total_shikake =17
     Through put ratio =0.846667
    36  Total_jitsu_kako_su =127
     Total_shikake =21
     Through put ratio =0.846667
    37  Total_jitsu_kako_su =119
     Total_shikake =27
     Through put ratio =0.793333
    38  Total_jitsu_kako_su =123
     Total_shikake =22
     Through put ratio =0.820000
    39  Total_jitsu_kako_su =122
     Total_shikake =25
     Through put ratio =0.813333
    40  Total_jitsu_kako_su =99
     Total_shikake =45
     Through put ratio =0.660000
    41  Total_jitsu_kako_su =119
     Total_shikake =25
     Through put ratio =0.793333
    42  Total_jitsu_kako_su =124
     Total_shikake =25
     Through put ratio =0.826667
    43  Total_jitsu_kako_su =100
     Total_shikake =46
     Through put ratio =0.666667
    44  Total_jitsu_kako_su =125
     Total_shikake =21
     Through put ratio =0.833333
    45  Total_jitsu_kako_su =116
     Total_shikake =33
     Through put ratio =0.773333
    46  Total_jitsu_kako_su =127
     Total_shikake =17
     Through put ratio =0.846667
    47  Total_jitsu_kako_su =128
     Total_shikake =18
     Through put ratio =0.853333
    48  Total_jitsu_kako_su =128
     Total_shikake =19
     Through put ratio =0.853333
    49  Total_jitsu_kako_su =128
     Total_shikake =21
     Through put ratio =0.853333
    50  Total_jitsu_kako_su =128
     Total_shikake =17
     Through put ratio =0.853333
    51  Total_jitsu_kako_su =129
     Total_shikake =21
     Through put ratio =0.860000
    52  Total_jitsu_kako_su =119
     Total_shikake =27
     Through put ratio =0.793333
    53  Total_jitsu_kako_su =114
     Total_shikake =33
     Through put ratio =0.760000
    54  Total_jitsu_kako_su =126
     Total_shikake =20
     Through put ratio =0.840000
    55  Total_jitsu_kako_su =125
     Total_shikake =19
     Through put ratio =0.833333
    56  Total_jitsu_kako_su =109
     Total_shikake =36
     Through put ratio =0.726667
    57  Total_jitsu_kako_su =130
     Total_shikake =16
     Through put ratio =0.866667
    58  Total_jitsu_kako_su =132
     Total_shikake =18
     Through put ratio =0.880000
    59  Total_jitsu_kako_su =137
     Total_shikake =10
     Through put ratio =0.913333
    60  Total_jitsu_kako_su =122
     Total_shikake =25
     Through put ratio =0.813333
    61  Total_jitsu_kako_su =124
     Total_shikake =23
     Through put ratio =0.826667
    62  Total_jitsu_kako_su =118
     Total_shikake =28
     Through put ratio =0.786667
    63  Total_jitsu_kako_su =130
     Total_shikake =17
     Through put ratio =0.866667
    64  Total_jitsu_kako_su =130
     Total_shikake =17
     Through put ratio =0.866667
    65  Total_jitsu_kako_su =127
     Total_shikake =22
     Through put ratio =0.846667
    66  Total_jitsu_kako_su =115
     Total_shikake =35
     Through put ratio =0.766667
    67  Total_jitsu_kako_su =117
     Total_shikake =28
     Through put ratio =0.780000
    68  Total_jitsu_kako_su =119
     Total_shikake =28
     Through put ratio =0.793333
    69  Total_jitsu_kako_su =123
     Total_shikake =24
     Through put ratio =0.820000
    70  Total_jitsu_kako_su =137
     Total_shikake =10
     Through put ratio =0.913333
    71  Total_jitsu_kako_su =107
     Total_shikake =43
     Through put ratio =0.713333
    72  Total_jitsu_kako_su =131
     Total_shikake =19
     Through put ratio =0.873333
    73  Total_jitsu_kako_su =135
     Total_shikake =9
     Through put ratio =0.900000
    74  Total_jitsu_kako_su =134
     Total_shikake =12
     Through put ratio =0.893333
    75  Total_jitsu_kako_su =119
     Total_shikake =31
     Through put ratio =0.793333
    76  Total_jitsu_kako_su =126
     Total_shikake =18
     Through put ratio =0.840000
    77  Total_jitsu_kako_su =131
     Total_shikake =14
     Through put ratio =0.873333
    78  Total_jitsu_kako_su =117
     Total_shikake =27
     Through put ratio =0.780000
    79  Total_jitsu_kako_su =118
     Total_shikake =28
     Through put ratio =0.786667
    80  Total_jitsu_kako_su =114
     Total_shikake =32
     Through put ratio =0.760000
    81  Total_jitsu_kako_su =108
     Total_shikake =36
     Through put ratio =0.720000
    82  Total_jitsu_kako_su =125
     Total_shikake =19
     Through put ratio =0.833333
    83  Total_jitsu_kako_su =122
     Total_shikake =22
     Through put ratio =0.813333
    84  Total_jitsu_kako_su =132
     Total_shikake =14
     Through put ratio =0.880000
    85  Total_jitsu_kako_su =106
     Total_shikake =38
     Through put ratio =0.706667
    86  Total_jitsu_kako_su =137
     Total_shikake =10
     Through put ratio =0.913333
    87  Total_jitsu_kako_su =122
     Total_shikake =27
     Through put ratio =0.813333
    88  Total_jitsu_kako_su =129
     Total_shikake =21
     Through put ratio =0.860000
    89  Total_jitsu_kako_su =132
     Total_shikake =15
     Through put ratio =0.880000
    90  Total_jitsu_kako_su =114
     Total_shikake =35
     Through put ratio =0.760000
    91  Total_jitsu_kako_su =138
     Total_shikake =12
     Through put ratio =0.920000
    92  Total_jitsu_kako_su =109
     Total_shikake =40
     Through put ratio =0.726667
    93  Total_jitsu_kako_su =127
     Total_shikake =20
     Through put ratio =0.846667
    94  Total_jitsu_kako_su =125
     Total_shikake =19
     Through put ratio =0.833333
    95  Total_jitsu_kako_su =98
     Total_shikake =47
     Through put ratio =0.653333
    96  Total_jitsu_kako_su =119
     Total_shikake =28
     Through put ratio =0.793333
    97  Total_jitsu_kako_su =123
     Total_shikake =21
     Through put ratio =0.820000
    98  Total_jitsu_kako_su =114
     Total_shikake =33
     Through put ratio =0.760000
    99  Total_jitsu_kako_su =127
     Total_shikake =20
     Through put ratio =0.846667
    
[/code]


CC BY-SA 4.0
2021-05-12T11:19:41.713
75803
2021-05-12T12:09:24.700
2021-05-12T11:52:54.060
3060
45103
question
c
プログラムを書き換えたい


変数を一つ用意し、そこに、出力結果の「Through put ratio」を全て足して行き、最後に100で割りましょう。  
それでお望みのことができます


CC BY-SA 4.0
2021-05-12T12:09:24.700
75804
2021-05-12T12:09:24.700
27481
75803
answer