Technical Information

About the random generator chiselVse phenomena and processes in society are of two types – random and regular. Let's try to look at the random processes with foreshortening programmer, about the events that occur naturally and so we all know. In programming, to extract the random values devised a special mechanism, which is called – the random number generator. Of course, the generation is not random, all processes interconnected at the program time. That is, from a software timer and formed these so-called random numbers.

Ie in fact, is true to call such a mechanism – a pseudorandom number generator, although Algorithms for the latest results from the sample of operators admit out randomly. Every single event, which is in programming, user interaction with operatorov.Rassmotrim their details. Function rand, srandV programming in C (B) plays a great role-sensitive, so to the detriment of the attractiveness of this subtitle, operator names begin with a capital letter. From this it follows that it is necessary to strive for accuracy, not picture. In order to be a random number generator gave us a random number – used the function rand.

Application of our functions would be better to show an example: int g = rand (); At tekuschemprimere clearly seen that the result of the function an integer result. Random value ranges from zero to a constant, and this constant is initialized in the directive, where that operator. Try running a program that displays a random value on the screen, only no one, but several times. But, unfortunately, result in any startup, will be every time you see one and the same value. The fact is that when you compile the program, the existing function of rand debugged in the memory of a specific program at startup time and are always drawn to it by this time. Brainy programmers were able to find a solution to this situation, the operator came up with srand. Its functionality is very easy – for any treatment program to the function rand, initialize the system timer. It turns out that this statement every time will apply to the current time, which, of course, every time a change (seconds still struggling). Function randomVoobsche something predviduschih studied features missing that would have to write applications of varying complexity, using a random number generator. Random operator introduced not so long ago, and in programming in C + +. He concludes in currently several improvements: increased range, the process of generating random numbers was perfect.