MeehoweCK

Untitled

Nov 19th, 2020
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     srand(time(nullptr));
  10.     int x = rand();             // interval of x: <1; 32767>
  11.     int y = x - 1;              // interval of y: <0; 32766>
  12.     double z = 1.0 * y / 32766; // interval of z: <0; 1>
  13.     cout << z << endl;
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment