Thanks for the answers and comments. Andrei wrote to me: Such questions usually mean: "Maybe someone will write for me?" No, Andrei, I do not need to give someone else for my own, I am 52 years old, I do not study in any educational institution. My goal is to learn myself, including through the work of other people. When I started learning C ++ (I have now mastered 11 lessons from 22), I tried to solve everything myself, in the end I spent a lot of time, in particular, the problem “How to become a millionaire” (TV game), I did more than a month (almost puffed over this task every day) and although it is a huge benefit from this, even if we spend time so much, it’s superfluous. Now, if something relatively quickly does not work, I’m looking for an answer in the Internet (only to save time), then I try to work it out to automatism. About my question. There are your answers that, in order to understand, I just don’t have enough knowledge. The smartest answer was given to me by Mikillskegg, everything is very clear, but I found a pitfall in this algorithm: let's say we make an array in ascending order, if the first or any (by index) random number is the maximum possible number of the rand () range, no further increase will be possible. Why it was in this way that I decided to derive an ordered sequence from random numbers, because there are other ways, just testing different methods. Here I discovered the underwater stone - use.