/* * To input an array and print all inversion pairs in it * @author-Karan Narain(karan@iitk.ac.in) * */ #include #include int inversion_pair(int A[],int n) { int i,j,count=0; //count holds the number of inversion pairs for(i=0;iA[j]) { printf("(%d,%d) ",i,j); count++; } } } return count; } int main() { int A[10],temp,i=0,len,count; //len holds the number of elements in array A.It would be equal to the last value of i before thw while loop ends or breaks while(i<10) { printf("Enter an element(To stop entering,enter a non-positive number\n"); scanf("%d",&temp); if(temp<=0) break; else { A[i]=temp; i++; } } len=i; printf("The array you entered is :\n"); for(i=0;i