srand(time(nullptr));
#include
#include
srand(time(nullptr));
int random_value = rand();
Один раз инициализируем через srand, а потом сколько угодно генерируем через rand. #include
#include
using namespace std;
class Random {
public:
Random() {
random_device device;
gen.seed(device());
}
int next(int first, int last) {
uniform_int_distribution range(first, last);
return range(gen);
}
private:
mt19937 gen;
};
int main() {
system("chcp 1251 > nul");
Random rand;
while (true) {
const auto a = rand.next(0, 9);
const auto b = rand.next(0, 9);
cout << a << " * " << b << " = ?\nВведите ответ: ";
int c;
cin >> c;
puts(c == a * b ? "Верно!" : "Неверно");
}
}