冒泡排序为何结果输出不正确?
/* 输入20个成绩不用冒泡法从低到高排序*/#include "stdio.h"
#define N 20
int main(void)
{
void sort(float *array,int n);
int i;
float B[N],*point;
printf("please enter the scores of sporters:\n");
point=B;
for(i=0;i<N;i++)
scanf("%f",point++);
point=B;
sort(point,N);
printf("\nouput the scores of invered:\n");
point=B;
for(i=0;i<N;i++)
printf("%.1f",*point++);
putchar('\n');
getch();
return 0;
}
void sort(float *array,int n)
{
int i,j;
float temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i;j++)
if(*(array+j)>*(array+j+1))
{
temp=*(array+j);
*(array+j)=*(array+j+1);
*(array+j+1)=temp;
}
}
return;
}