https://vjudge.net/problem/UVA-10327
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=1000+10;
int n,m;
int a[maxn];
int main(){
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++)scanf("%d",&a[i]);
bool flag=true;
int ans=0;
while(flag){
flag=false;
for(int i=0;i<n-1;i++)
if(a[i]>a[i+1]){
swap(a[i],a[i+1]);
ans++;
flag=true;
}
}
printf("Minimum exchange operations : %d\n",ans);
}
}