You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
399 B
20 lines
399 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 10010;
|
|
int a[N];
|
|
int n, cnt;
|
|
|
|
int main() {
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) cin >> a[i];
|
|
|
|
for (int i = 1; i < n; i++)
|
|
for (int j = i + 1; j <= n; j++)
|
|
if (a[i] > a[j]) {
|
|
cnt++;
|
|
swap(a[i], a[j]);
|
|
}
|
|
cout << cnt << endl;
|
|
return 0;
|
|
} |