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