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, pos, 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 (pos=length-1; pos>0; pos--)
  21. {
  22. for (i=0; i<pos; i++)
  23. {
  24. if (A[i]>A[i+1])
  25. {
  26. int a = A[i];
  27. A[i] = A[i+1];
  28. A[i+1] = a;
  29. }
  30. }
  31. }
  32. for (i=0; i<length; i++)
  33. {
  34. printf("%d ", A[i]);
  35. }
  36. stop = clock();
  37. printf("\nВремя выполнения: %f сек.", ((double) (stop - start)) / CLK_TCK);
  38. return 0;
  39. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
Массив до:
-321 -628 -985 861 -68 774 -694 808 646 528 -301 521 643 499 -429 948 -354 734 -474 -466 -777 61 -822 -928 -574 180 -420 -739 -125 397 
Массив после:
-985 -928 -822 -777 -739 -694 -628 -574 -474 -466 -429 -420 -354 -321 -301 -125 -68 61 180 397 499 521 528 643 646 734 774 808 861 948 
Время выполнения: 0.000000 сек.