Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,i,j,l,temp,count=0,k,a[150],n;
- cin>>t;
- for(l=1;l<=t;l++)
- {
- cin>>n;
- count=0;
- for(i=1;i<=n;i++)
- cin>>a[i];
- for(i=1;i<=n;i++)
- {
- if(a[i]!=i)
- {
- for(j=i+1;j<=n;j++)
- {
- if(a[j]==i)
- {
- temp=a[j];
- a[j]=a[i];
- a[i]=temp;
- count++;
- }
- }
- }
- }
- cout<<"Case "<<l<<": "<<count<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement