fork download
  1. #include <iostream>
  2. #include <functional>
  3. #include <chrono>
  4. #include <random>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. auto seed = chrono::system_clock::now().time_since_epoch().count();
  10. auto engine = default_random_engine{seed};
  11. auto dice = uniform_int_distribution<int>{1,6};
  12. auto d12 = uniform_int_distribution<int>{1,12};
  13. auto roll = bind( dice, engine );
  14. auto roll12 = bind( d12, engine );
  15.  
  16. for(int i = 0; i < 100; ++i)
  17. {
  18. cout << roll() << "\n";
  19. cout << roll12() << "\n\n";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
3
6

1
1

1
2

1
1

4
8

2
4

5
9

5
10

3
5

6
11

4
7

5
10

1
1

2
4

2
3

4
7

6
11

6
11

5
9

6
11

4
8

3
5

1
2

1
1

6
12

5
10

6
11

6
12

4
8

2
4

5
9

2
4

1
2

1
2

6
11

2
4

1
2

6
11

2
4

4
7

4
7

4
8

1
1

5
10

5
9

2
4

1
1

3
6

6
11

1
1

3
5

3
5

3
5

5
10

6
11

2
3

4
7

4
7

3
6

2
3

3
6

6
12

2
3

1
2

2
3

2
3

5
9

5
10

4
7

6
12

1
2

6
12

3
5

6
12

1
1

4
7

5
9

3
5

2
3

6
12

2
4

6
11

4
8

1
2

4
7

1
2

2
3

4
8

2
3

4
7

6
11

4
8

6
12

3
5

2
3

4
7

6
11

2
4

2
4

2
3