fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7. clock_t start, stop;
  8. start = clock();
  9. printf("Массив до:\n");
  10. int length=30;
  11. int A[length];
  12. int i, j, Xmin = -1000, Xmax = 1000;
  13. srand(time(NULL));
  14. for (i=0; i<length; i++)
  15. {
  16. A[i] = -1000+rand()%(Xmax-Xmin+1);
  17. printf("%d ", A[i]);
  18. }
  19. printf("\nМассив после:\n");
  20. for (i=0; i<length; i++)
  21. {
  22. int Amin=A[i];
  23. for (j=i+1; j<length; j++)
  24. if (Amin>A[j])
  25. {
  26. int a = Amin;
  27. Amin = A[j];
  28. A[j] = a;
  29. }
  30. printf("%d ", Amin);
  31. }
  32. stop = clock();
  33. printf("%f", ((double) (stop - start)) / CLK_TCK);
  34. return 0;
  35. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Массив до:
999 -816 174 -320 952 363 373 447 -903 470 -486 244 170 -325 362 524 -202 -420 -931 -18 516 102 431 476 75 444 840 -92 -800 -160 
Массив после:
-931 -903 -816 -800 -486 -420 -325 -320 -202 -160 -92 -18 75 102 170 174 244 362 363 373 431 444 447 470 476 516 524 840 952 999 0.000000