📄 l92.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -