Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long n,i,a[1000],j,count,t;
- while(scanf("%lld",&n)==1)
- {
- count=0;
- for(i=0;i<n;i++)
- scanf("%lld",&a[i]);
- for(i=0;i<n-1;i++)
- {
- for(j=0;j<n-1;j++)
- {
- if(a[j]>a[j+1])
- {
- count++;
- t=a[j];
- a[j]=a[j+1];
- a[j+1]=t;
- }
- }
- }
- printf("Minimum exchange operations : %lld\n",count);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment