又是排序问题..........
选择排序法...#include <stdio.h>
#define N 10
int main()
{
int num[N] = {0};
int i = 0;
int j = 0;
int temp = 0;
int max = 0;
for (i=0; i<N-1; i++)
{
scanf("%d",&num[i]);
}
for (i=0; i<N-1; i++)
{
max = num[i];
for (j=i+1; j<N; j++)
{
if (max<num[j])
{
max = num[j];
}
}
temp = num[i];
num[i] = max;
max = temp;
}
for (i=0; i<N-1; i++)
{
printf("%4d",num[i]);
}
return 0;
}
哪个地方错了?排不出来呀
另外,有个 快速选择排序法 ,算法看明白了,但编不出来,大家帮一下忙!!!谢谢了