http://uva.onlinejudge.org/external/103/10327.html
#include<stdio.h> int main(void){ int n,i,j,count=0; int array[1000]; while (scanf("%d",&n) != EOF) { count = 0; for (i = 0; i < n; i++) { scanf("%d",&array[i]); } for (i = 0; i < n; i++) { for (j=i+1; j<n; j++) { if (array[i]>array[j]) { count++; } } } printf("Minimum exchange operations : %d\n",count); } return 0; }