fork(3) download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. const int mval = 500;
  5. int r[1001];
  6.  
  7. int coot[501];
  8.  
  9. int j=0;
  10. int i=0;
  11.  
  12. int main(){
  13.  
  14. for(i; i<20; i++){
  15. r[i] = rand() % 501;
  16. coot[r[i]]++;
  17. printf("%i, ", r[i]);
  18. }
  19.  
  20. printf("\n");
  21.  
  22. for(i=0; i<mval; i++)
  23. while(coot[i]>0){
  24. r[j] = i;
  25. coot[i]--;
  26. j++;
  27. printf("%i, ", i);
  28. }
  29.  
  30. return 0;
  31.  
  32. }
Success #stdin #stdout 0s 1836KB
stdin
Standard input is empty
stdout
7, 406, 105, 487, 113, 52, 490, 57, 498, 388, 50, 439, 80, 421, 131, 253, 129, 309, 208, 28, 
7, 28, 50, 52, 57, 80, 105, 113, 129, 131, 208, 253, 309, 388, 406, 421, 439, 487, 490, 498,