Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- while(scanf("%d",&n)!=EOF)
- {
- int x[n+5],tmp,cnt=0;
- for(int i=1;i<=n;i++) scanf("%d",&x[i]);
- for(int i=1;i<n;i++)
- {
- for(int j=1;j<n;j++)
- {
- if(x[j]>x[j+1])
- {
- tmp=x[j];
- x[j]=x[j+1];
- x[j+1]=tmp;
- cnt++;
- }
- }
- }
- printf("Minimum exchange operations : %d\n",cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement