Guest User

Untitled

a guest
Dec 2nd, 2019
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int cnt = 0;
  5.  
  6. int main() {
  7. srand(0);
  8. int arr[100000];
  9. int n;
  10. cin >> n;
  11. for (int k = 0; k < 7; ++k) {
  12. cnt = 0;
  13. for (int i = 0; i < n; ++i) {
  14. arr[i] = rand() % 10000;
  15. }
  16. for (int i = 1; i < n; ++i) {
  17. for (int j = i - 1; j >= 0 && arr[j + 1] < arr[j]; --j) {
  18. cnt += 3;
  19. swap(arr[j + 1], arr[j]);
  20. }
  21. }
  22. cout << cnt << endl;
  23. }
  24.  
  25. return 0;
  26. }
RAW Paste Data