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 0.01s 5284KB
stdin
Standard input is empty
stdout
Массив до:
-382 -340 785 -595 24 444 252 -400 -583 -406 22 183 884 -386 -976 -375 -18 -908 -429 449 226 695 -568 -568 592 83 532 -232 -878 501 
Массив после:
-976-908-878-595-583-568-568-429-406-400-386-382-375-340-232-18222483183226252444449501532592695785884
Время выполнения: 0.000000 сек.