冒泡排序思想
#include <iostream>
using namespace std;
const int N = 1e4+10;
int n;
int nums[N];
int main()
{
cin >> n;
int ans =0;
for(int i=1;i<=n;i++) cin >> nums[i];
for(int i=1;i<=n;i++)
{
int index = i;
for(int j=i+1;j<=n;j++)
{
if(nums[index] > nums[j]) index = j;
}
// exchange
if(index!=i)
{
ans ++;
int tmp = nums[index];
nums[index] = nums[i];
nums[i] = tmp;
}
}
cout << ans;
return 0;
}