#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int selectionSort(int *A, int N){
int count=0;
for(int i=0;i<N;i++){
int minj=i;
for(int j=i;j<N;j++){
if(A[j]<A[minj]){
minj=j;
}
}
if(i!=minj)count++;
std::swap(A[i],A[minj]);
}
return count;
}
int main() {
// your code goes here
int N,A[101];
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d",&A[i]);
}
int c=selectionSort(A,N);
for(int i=0;i<N;i++){
if(i>0)printf(" ");
printf("%d",A[i]);
}
printf("\n%d\n",c);
return 0;
}
最終更新:2016年03月30日 06:47