Skip to content

Instantly share code, notes, and snippets.

@TyeolRik
Last active September 5, 2019 10:53
Show Gist options
  • Save TyeolRik/367bc82bc7e4c62b9b891bd386f4de35 to your computer and use it in GitHub Desktop.
Save TyeolRik/367bc82bc7e4c62b9b891bd386f4de35 to your computer and use it in GitHub Desktop.
[C++] Make Random Number
#include <iostream>
#include <cstdlib>
#include <ctime>
double makeRandomDouble() {
return (double)rand() / RAND_MAX;
}
int main()
{
srand((unsigned int)time(NULL)); // For making random number (set seed)
for (int i = 0; i < 100; i++) {
printf("%d\n", rand());
printf("%lf\n", makeRandomDouble()); // Making double random number
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment