fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int Count[10];
  7.  
  8. int main() {
  9. srand(time(0));
  10. int q = 0;
  11. for (int i=0;i<100000;i++){
  12. double num = (double)rand() / ((double)rand() + 0.1);
  13. double r = num - floor(num);
  14. Count[(int)(r*10)]++;
  15. }
  16. for (int i=0;i<10;i++)
  17. cout << Count[i]<<" ";
  18. return 0;
  19. }
Success #stdin #stdout 0.02s 3460KB
stdin
Standard input is empty
stdout
12577 11752 11221 10279 9889 9612 9182 8569 8646 8273