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. {
  25. if (Amin>A[j])
  26. {
  27. int a = Amin;
  28. Amin = A[j];
  29. A[j] = a;
  30. }
  31. }
  32. printf("%d ", Amin);
  33. }
  34. stop = clock();
  35. printf("\nВремя выполнения: %f сек.", ((double) (stop - start)) / CLK_TCK);
  36. return 0;
  37. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Массив до:
-653 -663 211 -53 -381 -46 -4 323 510 -308 731 -168 554 806 -973 -685 154 -538 248 -211 -584 -431 -66 973 594 386 -223 -746 -963 -63 
Массив после:
-973 -963 -746 -685 -663 -653 -584 -538 -431 -381 -308 -223 -211 -168 -66 -63 -53 -46 -4 154 211 248 323 386 510 554 594 731 806 973 
Время выполнения: 0.000000 сек.