fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. srand(time(NULL));
  6. double a = 0, b;
  7. for(int i = 0; i < 1000; i++){
  8. a += (double)rand() * 2 / RAND_MAX - 1;
  9. }
  10. b = a / 1000.0;
  11. cout << b;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4484KB
stdin
Standard input is empty
stdout
-0.0435333