#include <iostream>
#include <random>
int rnd(int min, int max) {
std::random_device rd;
std::default_random_engine generator(rd());
std::uniform_int_distribution<int> distribution(min, max);
return distribution(generator);
}
int main() {
int (*func_ptr)(int, int) = &rnd;
for (int i = 0; i < 10; ++i) {
std::cout << (*func_ptr)(5, 10) << std::endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <random>
int rnd(int min, int max) {
std::random_device rd;
std::default_random_engine generator(rd());
std::uniform_int_distribution<int> distribution(min, max);
return distribution(generator);
}
int main() {
int (*func_ptr)(int, int) = &rnd;
for (int i = 0; i < 10; ++i) {
std::cout << (*func_ptr)(5, 10) << std::endl;
}
return 0;
}