/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <random>
using namespace std;
int getRandomNumber (int min, int max) {
// μ¨λ μ€μ
random_device rd;
mt19937 seed(rd());
//λΆν¬ μ€μ
uniform_int_distribution<int> range(min, max);
//λλ€ κ° μμ±
return range(seed);
}
int main()
{
const int MIN = 1;
const int MAX = 45;
int arr[MAX+1];
int pickedBall;
// μ΄κΈ°ν μμ
for (int i=MIN; i<=MAX; i=i+1) {
arr[i] = 0;
}
// μ΄ 7κ°μ μλ₯Ό λ½μ
for (int i=1; i<=7; i++) {
while(true) {
pickedBall = getRandomNumber(MIN, MAX);
if (arr[pickedBall]==0) { // μ΄μ μ λ½μλμ§ νμΈ
break; // λ½μ μ μ΄ μλ€λ©΄ OK
}
}
if (i==7) {
cout << " (BONUS: " << pickedBall << ")" << endl;
} else {
arr[pickedBall] = 1; // λ½μλ€κ³ νμ
cout << pickedBall << " ";
}
}
return 0;
}