Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (36 sloc) 0.478 kB
//Ñ¡ÔñÅÅÐò£¬²»Îȶ¨
#include <iostream>
using namespace std;
void SelectSort(int *p, int n)
{
int i, j, k;
int temp;
for(i=0; i<n-1; i++)
{
k = i;
for(j=i; j<n; j++)
{
if(p[j] < p[k])
k = j;
}
if(k != i)
{
temp = p[i];
p[i] = p[k];
p[k] = temp;
}
}
}
int main()
{
int *p = new int[100];
int i, n;
cin >> n;
for(i=0; i<n; i++)
cin >> p[i];
SelectSort(p,n);
for(i=0; i<n; i++)
cout << p[i] << " ";
cout << endl;
return 0;
}
Jump to Line
Something went wrong with that request. Please try again.