#include
void down(int array[],int n);//将函数声明放在头上
void main(void)
{
int i;
int mark[10] = {98, 88, 99, 56, 68, 77, 48, 100, 46, 23};
down(mark,10);//去掉[],这里是地址传值
printf("从小到大的顺序为\n");
for (i=0; i<5; i++)
{
printf("%5d", mark[i]);
}
printf("\n");
for (i=5; i<10; i++)
{
printf("%5d", mark[i]);
}
printf("\n");
}
void down(int array[],int n)
{
int i, j, k, t;
for (i=0; i
k = i;
for (j=i+1; j
if (array[j] < array[k])
{
k = j;
}
if (k != i)//缺少交换条件,交换数据错误
{
t = array[i];
array[i] = array[k];
array[k] = t;
}
}
}
}