#include <iostream>
using namespace std;
void select_sort(int *,int);
int main()
{
int num[50];
int n,i;
cin>>n;
for(i=0;i<n;i++)
{
cin>>num[i];
}
select_sort(num,n);
for(i=0;i<n;i++)
{
cout<<num[i]<<" ";
}
cout<<endl;
return 0;
}
void select_sort(int *p, int n)
{
int i,j,t;
int min_site=0;
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(*(p+j)<*(p+min_site))
{
min_site=j;
}
}
t=*(p+i);
*(p+i)=*(p+min_site);
*(p+min_site)=t;
min_site=i+1;
}
}
运行结果