📄 changesort.c
字号:
#include <stdio.h>
#define seqListDataSize 50
typedef seqListDataType int
typedef struct
{
recordDataType element[recordDataSize];
int length;
}seqList
void bubbleSort(seqList *l)
{
int i,j,change=1;
for(i=l.length;i>1 && change;i--)
{
change=0;
for(j=1;j<i;j++)
{
if(l.element[j]>l.element[j+1])
{
l.element[0]=l.elemnt[j];
l.element[j]=l.element[j+1];
l.element[j+1]=l.element[0];
change=1;
}
}
}
}
int quickPass(seqList *l,int left,int right)
{
int low=left;
int high=right;
l.element[0]=l.element[left];
while(low<high)
{
while(low<high && l.element[0]<l.element[high])
high--;
if(low<high)
{
r[low]=r[high];
low++;
}
while(low<high && l.element[0]>l.element[low])
low++;
if(low<high)
{
l.element[high]=l.element[low];
high--;
}
}
l.element[low]=l.element[0];
return low;
}
void quickSort(seqList *l,int low,int high)
{
if(low<high)
{
pos=quickPass(l,low,high);
quickSort(l,low,pos-1);
quickSort(l,pos+1,high);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -