说明:以下C++代码的实现参考严蔚敏的《数据结构(C语言版)》
实验目的:有序列{{49,1},{38,2},{65,3},{97,4},{76,5},{13,6},{27,7},{49,8}};其中{a,b}把a视为key,按照key的大小使用插入排序对序列进行排序
算法图示:
实验代码:
c10_1.cpp
#ifndef C10_1_H
#define C10_1_H
#include <iostream>
using namespace std;
#define MAXSIZE 20
typedef int KeyType;
typedef int InfoType;
typedef struct
{
KeyType key;
InfoType info;
}RedType;
typedef struct
{
RedType r[MAXSIZE+1];//r[0]闲置,用作哨兵单元......
阅读全文