Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // готово
- #include <iostream>
- #include <ctime>
- using namespace std;
- int c = 0;
- int main() {
- int arr[100000];
- srand(0);
- int n;
- cin >> n;
- for (int k = 0; k < 7; ++k) {
- for (int i = 0; i < n; ++i) {
- arr[i] = rand() % 10000;
- }
- c = 0;
- for (int i = 0; i < n; ++i) {
- c += 1;
- int cnt = 0;
- for (int j = i + 1; j < n; ++j) {
- ++c;
- if (arr[i] > arr[j]) {
- cnt++;
- c += 3;
- swap(arr[i], arr[j]);
- }
- }
- if (cnt == 0) break;
- c += 1;
- }
- cout << c << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement