1#include <iostream>
2#include <ctime>
3#include <cstdlib>
4using namespace std;
5int main()
6{
7 srand(time(0)); // Initialize random number generator.
8
9 cout<<"Random numbers generated between 1 and 10:"<<endl;
10 for(int i=0;i<10;i++)
11 cout << (rand() % 10) + 1<<" ";
12 return 0;
13}
14
1#include <iostream>
2#include <string>
3#include <random>
4
5int main() {
6 std::mt19937 gen (123);
7 std::uniform_real_distribution<double> dis(0.0, 1.0);
8 double x = dis(gen);
9 std::cout << x << std::endl;
10}