Last active
September 5, 2019 10:53
-
-
Save TyeolRik/367bc82bc7e4c62b9b891bd386f4de35 to your computer and use it in GitHub Desktop.
[C++] Make Random Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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