A
A
Andrey Kulagin2021-04-22 14:51:52
random numbers
Andrey Kulagin, 2021-04-22 14:51:52

How to display two random non-repeating numbers in SI?

How to display two random non-repeating numbers in SI in the range from 0 to 10?

srand(time(NULL));
int a = rand()%9;
int b = rand()%9;

Here the numbers are random, but can be repeated

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
12rbah, 2021-04-23
@andrew_1985

The simplest algorithm is this: generate a number, remember it, at the next generation check whether the number is equal to the previous one, if yes, generate it again, if not, output it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question