rng cpp

Solutions on MaxInterview for rng cpp by the best coders in the world

showing results for - "rng cpp"
Lilli
11 Apr 2017
1// Add thus to with the headers
2mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
3// Generate a function that will give values between l and r inclusive
4auto dist = uniform_int_distribution<int>(l, r);
5// get the random number using dist(rng);
Clara
01 Oct 2020
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctime>
4
5int main() {
6  srand((unsigned) time(0));
7    printf("Your dice has been rolled! You got: \n ");
8    int result = 1 + (rand() % 6);
9    printf("%d \n", result);
10   switch (result) {
11    case 1:
12        printf("Your prize is our original T-shirt!");
13        break;
14    case 2:
15        printf("Your prize is our original cap!");
16        break;
17    case 3:
18        printf("Your prize is our original necklace!");
19        break;
20    case 4:
21        printf("Your prize is our original keychain!");
22        break;
23    case 5:
24        printf("Your prize is our original cup set!");
25        break;
26    case 6:
27        printf("Your prize is a set of original keychains!");
28        break;
29    default:
30        printf("Error");
31        break;
32    }
33}