Guest User

Untitled

a guest
Feb 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3.  
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8.  
  9.     int OWin=0;
  10.     int DWin=0;
  11.  
  12.  
  13.     // seed with random time
  14.     srand(time(NULL));
  15.  
  16.     for(int x=1; x<1000000;x++)
  17.     {
  18.         int RollO=0;
  19.         int RollD=0;
  20.  
  21.         for(int y=1; y<9; y++)
  22.         {
  23.             int rand_num = rand() % 6 + 1;
  24.             RollO=RollO+rand_num;
  25.         }
  26.  
  27.         for(int z=1; z<9; z++)
  28.         {
  29.             int rand_num = rand() % 6 + 1;
  30.             RollD=RollD+rand_num;
  31.         }
  32.  
  33.         if(RollD>RollO)
  34.             DWin+=1;
  35.         else
  36.             OWin+=1;
  37.     }
  38.  
  39.     cout << "Offense Wins: " << OWin << endl;
  40.     cout << "Defense Wins: " << DWin << endl;
  41.  
  42.     cin.get();
  43.  
  44.     return 0;
  45.  
  46. }
Add Comment
Please, Sign In to add comment