fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <random>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. int main([[maybe_unused]] int argc,
  9. [[maybe_unused]] const char* argv[])
  10. {
  11. default_random_engine gen{random_device{}()};
  12. uniform_int_distribution<> dis(0, 60);
  13.  
  14. map<int,int> m;
  15.  
  16. for(int i = 0; i < 100000; ++i)
  17. {
  18. int r = dis(gen)-dis(gen);
  19. m[r]++;
  20. }
  21.  
  22. for(auto q: m)
  23. {
  24. cout << setw(3) << q.first << " ; " << setw(7) << q.second << endl;
  25. }
  26.  
  27. }
  28.  
Success #stdin #stdout 0.01s 4316KB
stdin
Standard input is empty
stdout
-60 ;       28
-59 ;       66
-58 ;       80
-57 ;      104
-56 ;      155
-55 ;      143
-54 ;      190
-53 ;      220
-52 ;      256
-51 ;      264
-50 ;      282
-49 ;      337
-48 ;      360
-47 ;      370
-46 ;      368
-45 ;      451
-44 ;      446
-43 ;      471
-42 ;      512
-41 ;      531
-40 ;      544
-39 ;      651
-38 ;      630
-37 ;      655
-36 ;      681
-35 ;      659
-34 ;      725
-33 ;      718
-32 ;      762
-31 ;      780
-30 ;      890
-29 ;      859
-28 ;      871
-27 ;      893
-26 ;      940
-25 ;     1016
-24 ;     1028
-23 ;     1033
-22 ;     1009
-21 ;     1034
-20 ;     1106
-19 ;     1182
-18 ;     1186
-17 ;     1222
-16 ;     1236
-15 ;     1209
-14 ;     1230
-13 ;     1313
-12 ;     1330
-11 ;     1249
-10 ;     1292
 -9 ;     1420
 -8 ;     1350
 -7 ;     1475
 -6 ;     1539
 -5 ;     1449
 -4 ;     1618
 -3 ;     1617
 -2 ;     1533
 -1 ;     1603
  0 ;     1581
  1 ;     1646
  2 ;     1602
  3 ;     1572
  4 ;     1573
  5 ;     1507
  6 ;     1458
  7 ;     1430
  8 ;     1406
  9 ;     1418
 10 ;     1404
 11 ;     1290
 12 ;     1372
 13 ;     1318
 14 ;     1252
 15 ;     1243
 16 ;     1219
 17 ;     1151
 18 ;     1119
 19 ;     1153
 20 ;     1050
 21 ;     1070
 22 ;     1019
 23 ;      998
 24 ;     1081
 25 ;     1028
 26 ;      907
 27 ;      877
 28 ;      855
 29 ;      861
 30 ;      821
 31 ;      832
 32 ;      794
 33 ;      725
 34 ;      735
 35 ;      695
 36 ;      700
 37 ;      651
 38 ;      642
 39 ;      614
 40 ;      567
 41 ;      540
 42 ;      512
 43 ;      476
 44 ;      469
 45 ;      445
 46 ;      353
 47 ;      393
 48 ;      335
 49 ;      341
 50 ;      296
 51 ;      265
 52 ;      234
 53 ;      225
 54 ;      172
 55 ;      164
 56 ;      116
 57 ;       92
 58 ;       91
 59 ;       43
 60 ;       31