为什么快速排列下面的代码跑不动呢,输入完就没有输出了
#include<stdio.h>
#include<string.h>
struct info
{
char name[100];
int score;
};
struct info temp;
struct info x[10];
int Qksort(struct info arr[],int low,int high)
{
int max = high;
int min = low;
int flag = 0;
temp = arr[low];
while(low<high)
{
while(arr[high].score > temp.score )
high--;
arr[low] = arr[high];
while (arr[low].score < temp.score)
low++;
arr[high] = arr[low];
flag++;
}
if(flag != 0)
{
arr[low] = arr[high] = temp;
Qksort(arr,min,high);
Qksort(arr,high+1,max);
}
}
int main()
{
int m = 10;
int i,j;
for (i=0; i<m; i++)
{
printf("输入第%d个学生的信息:",i+1);
scanf("%s %d",x[i].name,&x[i].score);
}
Qksort(x,0,9);
printf("使用快速排序对上面数据按成绩非递减排列:n");
for (i=0; i<m; i++)
{
printf("%s %dn",x[i].name,x[i].score);
}
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…