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)) / CLK_TCK);
  34. return 0;
  35. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Массив до:
843 317 756 -555 745 12 834 -44 -411 -285 654 898 893 263 -401 -929 -527 -436 -673 752 231 799 -148 -414 758 -420 -367 47 -509 -194 
Массив после:
-929 -673 -555 -527 -509 -436 -420 -414 -411 -401 -367 -285 -194 -148 -44 12 47 231 263 317 654 745 752 756 758 799 834 843 893 898 
Время выполнения: 0.000000 сек.