20th Dec 2017, 3:11 PM
Cool Codin
Cool Codin - avatar
+ 11
The rand function, declared in stdlib.h, returns a random integer in the range 0 to RAND_MAX (inclusive) every time you call it. On machines using the GNU C library RAND_MAX is equal to INT_MAX or 231-1, but it may be as small as 32767. There are no particularly strong guarantees about the quality of random numbers that rand returns, but it should be good enough for casual use, and has the advantage that as part of the C standard you can assume it is present almost everywhere. The problem with rand is that getting a uniform value between 0 and 231-1 may not be what you want. It could be that RAND_MAX is be too small; in this case, you may have to call rand more than once and paste together the results. But there can be problems with RAND_MAX even if it is bigger than the values you want. In C++, this constraint is relaxed, and a library implementation is allowed to advance the generator on other circumstances (such as calls to elements of <random>). The function accesses and modifies internal state objects, which may cause data races with concurrent calls to rand or srand. Some libraries provide an alternative function that explicitly avoids this kind of data race: rand_r (non-portable). C++ library implementations are allowed to guarantee no data races for calling this function.
22nd Dec 2017, 12:04 PM
MsJ
MsJ - avatar
+ 4
C++ мой любимий язик,я ево только начал учить три дня назад Он мне хорошо дается,лучше чем другие Я знаю пять яп: C++ Javascript Html Python Css Хотя html не щитается Яп но всо таки... также сейчас учу java но только начал поетому не внос ево в список Поетому я надеюсь на то што C++ не когда не умерет И ечо мне кажеться что html тоже будет жить вечно, он очень легкий,и если он умрот то веб-програмистов будет в два раза менше Ето мой код на C++(Работает только на ПК) В коде используется команда system("cls") Которая на интерпираторе Solorean не читпется (( Етот код писался на интерпираторе GGC Советую запускать код имено на ном! Писал програму на Code::Block https://code.sololearn.com/cVvf1vmhzzvN/?ref=app
22nd Dec 2017, 7:10 AM
Мистер Жека
Мистер Жека - avatar
0
The function rand () Returns always the same number to use the time function (0), which is located in the <time.h> library, and the current time is set to the current time on the device and then it turns out: int random = rand () * time (0 ); or you can put any mathematic sign instead of *, and in order to generate a random number within some limits, you need to divide it modulo into a limit: int random = rand () * time (0)% 10; In this example, I generated a random number between 0 and 10
27th Dec 2017, 8:54 AM
Мистер Жека
Мистер Жека - avatar
0
tanks
27th Dec 2017, 9:36 AM
Saadaqinho Ina Siyaad
Saadaqinho Ina Siyaad - avatar