Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. /*
  8.  * File:   main.cpp
  9.  * Author: fares
  10.  *
  11.  * Created on July 23, 2017, 2:38 PM
  12.  */
  13.  
  14. #include <cstdlib>
  15. #include<iostream>
  16. #include<ctime>
  17. using namespace std;
  18.  
  19. /*
  20.  *
  21.  */
  22.  
  23. //function to throw two dice
  24. void ThrowTwoDice(int&d1, int&d2)
  25. {
  26.     d1 = rand()%6 + 1;
  27.     d2 = rand()%6 + 1;
  28. }
  29.  
  30.  
  31. int main(int argc, char** argv) {
  32.     int dice1,dice2;
  33.     int counter =0;
  34.     int const arr1[6][2] = {{1,1},{2,2},{3,3},{4,4},{5,5},{6,6}};
  35.     int arr2[6][2];
  36.    
  37.     srand(0);
  38.     //Throw 2 dice 6 times, store in an array
  39.     do{
  40.     for(int i=0;i<6;i++)
  41.     {
  42.         ThrowTwoDice(dice1,dice2);
  43.         arr2[i][0] = dice1;
  44.         arr2[i][1]=dice2;
  45.     }
  46.     //Print content of arr2
  47.     cout << "{";
  48.     for(int i=0;i<6;i++)
  49.     {
  50.         cout<<  "{"<<arr2[i][0]<<","<<arr2[i][1]<<"}  ";
  51.     }
  52.     cout<<"}";
  53.     //Compare arrays
  54.     cout  << "Counter = " << counter << endl << endl;
  55.     counter++;
  56.     }while( arr2!=arr1);
  57.    
  58.    
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement