Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- { //freopen("input.txt","r",stdin);
- int ar[1000];
- int n;
- while(scanf("%d",&n)==1)
- {
- for(int i=0; i<n; i++)
- cin>>ar[i];
- int count=0;
- for(int i=0; i<n-1; i++)
- {
- for(int j=0; j<n-1-i; j++)
- {
- if(ar[j]>ar[j+1])
- {
- count++;
- swap(ar[j],ar[j+1]);
- }
- }
- }
- cout<< "Minimum exchange operations : "<<count<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement