问题遇到的现象和发生背景
#include<stdio.h>
#define max 100
typedef struct{
int key;
}RecoedType;
typedef struct {
RecoedType r[max+1];
int length;
}RecoedList;
int QKPass(RecoedType r[],int low,int high){
RecoedType x=r[low];
while(low<high){
while(low<high&&r[high].key>x.key)
high--;
if(low<high)
{
r[low]=r[high];
low++;
}
while(low<high&&r[low].key<x.key)
low++;
if(low<high){
r[high]=r[low];
high--;
}
}
r[low]=x;
return low;
}
void QKSort( RecoedType r[],int low,int high){
RecoedType b[max+1];
int pos;
if(low<high){
pos=QKPass(r,low,high);
QKSort(r,low,pos-1);
QKSort(r,pos+1,high);
}
}
int main(){
RecoedList L;
printf("请输入数组长度:");
scanf("%d",&L.length);
int low,high;
printf("排序前:\n");
for(int i=1;i<=L.length ;i++){
scanf("%d,%d",&L.r[i].key);
}
QKSort(L.r,1,L.length );
printf("排序后:\n");
for( int i=1;i<=L.length;i++){
printf(" %d,%d",&L.r[i]);
}
return 0;
}
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果