排序的代码哪里有问题
void paixu(int a[],int n){
int i,j;
int temp;
for (i=0;i<n-1;i++){
for (j=1;j<n;j++){
if (a[i]>a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
}
完整代码:
#include <stdio.h>
#define NUMBER 5
void paixu(int a[],int n){
int i,j;
int temp;
for (i=0;i<n-1;i++){
for (j=1;j<n;j++){
if (a[i]>a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
}
int main(void)
{
int h[NUMBER];
int i;
for (i=0;i<NUMBER;i++){
printf("%d号学生:",i+1); scanf("%d",&h[i]);
}
paixu(h,NUMBER);
puts("升序排列");
for(i=0;i<NUMBER;i++)
printf("%d号学生:%d\n",i+1,h[i]);
return 0;
}