-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiceRolls.cpp
More file actions
46 lines (41 loc) · 727 Bytes
/
diceRolls.cpp
File metadata and controls
46 lines (41 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <vector>
using namespace std;
void print(vector<int>& vec)
{
cout << "( ";
for(auto v : vec)
cout << v << " ";
cout << ")" << endl;
}
void diceHelper(int dice, vector<int> &chosen)
{
if (dice == 0)
{
print(chosen);
}
else
{
for (int i = 1; i <= 6; i++)
{
//choose
chosen.push_back(i);
//explore
diceHelper(dice - 1, chosen);
//unchoose
chosen.pop_back();
}
}
}
void diceRoll(int dice)
{
vector<int> chosen;
diceHelper(dice, chosen);
}
int main()
{
int dice;
cout << "Enter number of die: ";
cin >> dice;
diceRoll(dice);
}