[数据结构] 直接插入排序

#include
#include 
#define N 100

//定义结构体,用于放置待排序元素的信息
typedef struct 
{
	int key;
	char otherinfo;
}ElemType;

//参数ElemType A[]:结构体数组,数组内元素的类型都是上面定义的结构体
//参数n:待排序元素的个数元素的个数
void InsertSort(ElemType A[],int n)
{
	int i,j,k=0,m=0;
	for(i=2;i<=n;i++) 		//遍历待排序数组
	{
		if(A[i].key

运行结果:
[数据结构] 直接插入排序_第1张图片

你可能感兴趣的:(数据结构,C/C++)