X
X
xzmyxz2016-07-10 15:32:31
C++ / C#
xzmyxz, 2016-07-10 15:32:31

Generate two random numbers and return them?

What is the best way to generate two numbers? With the help of srand(time) random gives a new number in a second, but you need it right away. Well, how to return them from the function. There was an idea to put them in an array, but as I understand it will not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sitev_ru, 2016-07-10
@sitev_ru

srand(time(NULL)); //где-то вначале программы
...
void get2rand(int &v1, int &v2) {
  v1 = rand();
  v2 = rand();
}
...
int a1, a2;
get2rand(a1, a2);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question