数据结构 选择排序
找出最小关键字进行排序
# include <stdio.h>
# include <stdlib.h>
#define MAXSIZE 100
#define KEYTYPE int
typedef struct
{
KEYTYPE key;
}RECORDNODE;
void selectsort(RECORDNODE r[ ],int n)
{
int i,j,k;
for(i=1;i<=n-1;i++)
{
k=i;
for(j=i+1;j<=n;j++)
if(r[j].key<r[k].key)
k=j;
if(k!=i)
{
r[0]=r[i];
r[i]=r[k];
r[k]=r[0];
}
}
}
main()
{
RECORDNODE r[7];
int i;
for(i=1;i<=6;i++)
scanf("%d",&r[i]);
selectsort(r,6);
for(i=1;i<=6;i++)
printf("%d",r[i]);
}