[C++] random
Updated:
개요
- 난수 생성
예제
- 코드
#include <iostream> #include <random> using namespace std; int main() { auto get = []() { default_random_engine generator(random_device{}()); uniform_int_distribution<int> distribution(0, 9); return distribution(generator); }; for (int i = 0; i < 5; ++i) { cout << get() << endl; } return 0; }
- 실행 결과 1
1 6 3 1 4
- 실행 결과 2
2 8 8 1 4