# | Likes | Tech tags | Title | Creator | Created date |
---|---|---|---|---|---|
1 | 1 |
2022-10-08 15:00
|
#include<iostream>
#include<ctime>
int main() {
//Seed the rng to avoid getting the same number every time.
//This only changes once per second. Use more precise clock if necessary.
srand(time(0));
std::cout << rand() << '\n';
return 0;
}
objects | ||
std::cout |
en.cppreference.com | cplusplus.com |
functions | ||
rand |
en.cppreference.com | cplusplus.com |
srand |
en.cppreference.com | cplusplus.com |
std::basic_ostream::operator<< |
en.cppreference.com | cplusplus.com |
time |
en.cppreference.com | cplusplus.com |
Generate a random integer using a random number generator.
Possible characteristics to optimize for are simplicity, quality of the RNG algorithm, and speed of the RNG algorithm.