Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(nullptr));
- int x = rand(); // interval of x: <1; 32767>
- int y = x - 1; // interval of y: <0; 32766>
- double z = 1.0 * y / 32766; // interval of z: <0; 1>
- cout << z << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment