l91.cpp
来自「这里面包括数据结构多数的算法」· C++ 代码 · 共 36 行
CPP
36 行
#include <stdio.h>
typedef int InfoType;
#define n 10 //假设的文件长度,即待排序的记录数目
typedef int KeyType; //假设的关键字类型
typedef struct { //记录类型
KeyType key; //关键字项
InfoType otherinfo; //其它数据项,类型InfoType依赖于具体应用而定义
} RecType;
typedef RecType SeqList[n+1]; //SeqList为顺序表类型,表中第0个单元一般用作哨兵
void main()
{
void InsertSort(SeqList R);
int i;
SeqList R;
printf("请输入欲排序的数:");
for (i=1;i<=n;i++)
scanf("%d",&R[i].key);
printf("排序前:");
for (i=1;i<=n;i++)
printf("%d ",R[i].key);
printf("\n");
InsertSort(R);
printf("排序后:");
for (i=1;i<=n;i++)
printf("%d ",R[i].key);
printf("\n");
}
//对顺序表R中的记录R[1..n]按递增序进行插入排序
void InsertSort(SeqList R)
{
//在此插入必要的语句
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?