#include #include #include #include #include using namespace std; #define A_MaxHP (13000.0) //以下キャラAの体力・攻撃力・チャンス度合い #define A_attack (2000.0) #define A_chance (4.0) #define B_MaxHP (13000.0) //以下キャラBの体力・攻撃力・チャンス度合い #define B_attack (2000.0) #define B_chance (6.0) #define Tmax (100) //1ラウンド中の合計ぶつかり回数(変更不要) #define Kmax (1000000) //何ラウンド行うか int main(void){ int k,i,F_count=0,AR_flag=0,BR_flag=0,flag=0; double A_HP,B_HP,r,C_SUM,r_SUM,ratio; srand((unsigned int)time(NULL)); /*---------------------------ラウンド数ループ---------------------------*/ for(k=0;k= r_SUM){ B_HP -= A_attack; if(B_HP <= 0){ i = Tmax; AR_flag += 1; //Bがやられた時Aの取得ラウンド数に+1 } } /*ここまで*/ /*Bに攻撃権が来た場合*/ else{ A_HP -= B_attack; if(A_HP <= 0){ i = Tmax; BR_flag += 1; //Aがやられた時Bの取得ラウンド数に+1 } } /*ここまで*/ } /*++++++++++++++++++++++++ここまで++++++++++++++++++++++++*/ //先にラウンド数2になった場合に勝利 if(AR_flag == 2){ flag += 1; //flagはAの勝利数、Bが勝った場合は変化なし AR_flag = 0; //各ラウンド取得数の初期化 BR_flag = 0; F_count += 1; //試合数カウント+1 } if(BR_flag == 2){ AR_flag = 0; BR_flag = 0; F_count += 1; } } /*---------------------------ここまで---------------------------*/ ratio = flag * 100.0 / (double)F_count; //「Aの勝利数」÷「試合数」×100=Aの勝率 cout << "flag=" << flag << endl; cout << "ratio=" << ratio << endl; return 0; }