/***************************************************/
/* Description:二、交换排序法:冒泡+快排(C语言源代码)
/* Date:2021/9/10
/* Author:汝南城
/****************************************************/
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 1000
/*交换排序算法基于的顺序表存储结构*/
typedef int KeyType;
typedef struct {
KeyType key;
char name[10];//other info
}RedType;
typedef struct {
RedType r[MAXSIZE + 1];
int length;
}SqList;
/*①冒泡排序*/
void Bubble_Sort(SqList *L,int n)
{
int i, j;
RedType temp;
for (i = 1; i <= n - 1; i++) /*i为趟数,n个元素需比较n-1趟*/
{
for (j = 1; j <= n - i; j++) /*j为每一趟比较的次数,每趟比较n-i次*/
{
if (L->r[j].key > L->r[j + 1].key)
{
temp = L->r[j];
L->r[j] = L->r[j + 1];
L->r[j + 1] = temp;
}
}
}
}
/*②改进的冒泡排序*/
void Im_Bubble_Sort(SqList* L, int n)
{
int i, j,flag=1;
RedType temp;
for (i = 1; i <=