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("\nВремя выполнения сортировки методом выбора: %f", ((double) (stop - start)) / CLOCKS_PER_SEC);
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
Массив до:
112 -656 219 -701 -692 -660 -123 565 714 327 96 -733 -926 101 140 722 -447 867 635 -580 12 -488 -517 249 401 -453 691 -170 425 864 
Массив после:
-926 -733 -701 -692 -660 -656 -580 -517 -488 -453 -447 -170 -123 12 96 101 112 140 219 249 327 401 425 565 635 691 714 722 864 867 
Время выполнения сортировки методом выбора: 0.000000