fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. const float rand_max = static_cast<float>(RAND_MAX);
  6.  
  7. int main() {
  8. float temp = 0.0;
  9. srand(time(NULL));
  10. for(int i=0; i<10; i++)
  11. {
  12. temp = rand()/(rand_max);
  13. cout << static_cast<int>(temp + 0.5) << " ";
  14. }
  15. cout << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 4400KB
stdin
Standard input is empty
stdout
0 0 0 1 1 1 0 1 0 1