Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * File: main.cpp
- * Author: fares
- *
- * Created on July 23, 2017, 2:38 PM
- */
- #include <cstdlib>
- #include<iostream>
- #include<ctime>
- using namespace std;
- /*
- *
- */
- //function to throw two dice
- void ThrowTwoDice(int&d1, int&d2)
- {
- d1 = rand()%6 + 1;
- d2 = rand()%6 + 1;
- }
- int main(int argc, char** argv) {
- int dice1,dice2;
- int counter =0;
- int const arr1[6][2] = {{1,1},{2,2},{3,3},{4,4},{5,5},{6,6}};
- int arr2[6][2];
- srand(0);
- //Throw 2 dice 6 times, store in an array
- do{
- for(int i=0;i<6;i++)
- {
- ThrowTwoDice(dice1,dice2);
- arr2[i][0] = dice1;
- arr2[i][1]=dice2;
- }
- //Print content of arr2
- cout << "{";
- for(int i=0;i<6;i++)
- {
- cout<< "{"<<arr2[i][0]<<","<<arr2[i][1]<<"} ";
- }
- cout<<"}";
- //Compare arrays
- cout << "Counter = " << counter << endl << endl;
- counter++;
- }while( arr2!=arr1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement