用程序实现五种排序;用菜单进行选择。

来源:百度知道 编辑:UC知道 时间:2024/06/28 15:04:24
【问题描述】
用C程序实现五种排序;用菜单进行选择。
将程序中随机产生的100个数据按递增的顺序排好。
输出的形式:数字大小逐个递增的数列。
【基本要求】
(1)实现起泡排序、直接插入排序、
简单选择排序、快速排序、希尔排序、
(2)待排序表的表长大于100,表中数据随机产生。
(3)输出界面的优化。

用C语言完成!!
3月15号19点为最后期限,谢谢各位大哥大姐啦!!!

要原代码,编译能通过.

只要实现题中五种排序,其余类型的排序都不要.

#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<time.h>
int n;

void InsertSort(int L[]) {
// 对顺序表L作直接插入排序
int i,j;
for (i = 2; i <= n; ++i)
if (L[i] < L[i-1]) {
L[0] = L[i];
for (j = i-1; L[0] < L[j]; --j)
L[j+1] = L[j];
L[j+1] = L[0];
}
} // InsertSort

void BInsertSort(int L[]) {
// 对顺序表L作折半插入排序
int i,j,high,low,m;
for (i = 2; i <= n; ++i) {
L[0] = L[i];
low = 1; high = i-1;
while (low <= high) {
m = (low+high) / 2;
if (L[0] < L[m]) high = m-1;
else low = m + 1;
}
for (j = i-1; j >= high+1; --j) L[j+1] = L[j];
L[high+1] = L[0];
}
} // BInsertSort

void ShellInsert(int L[], int dk) {
// 对顺序表L作一趟希尔插入排序
int i,j;
for (i = dk+1; i <=