#include <iostream>
#include <random>
int main() {
// Obtain a random number from hardware
std::random_device rd;
// Seed the random number generator
std::mt19937 gen(rd());
// Define the distribution (uniform integer distribution between 1 and 100)
std::uniform_int_distribution<> dist(1, 100);
// Generate and print a random number
int random_num = dist(gen);
std::cout << "Random number: " << random_num << std::endl;
return 0;
}
C++ random number
最新推荐文章于 2024-08-10 22:58:42 发布