/*
功能:03计数排序
作者:wind
日期:2014-01-11
*/
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 10;
typedef int KeyType;
typedef struct
{
KeyType key;
char data;
}RedType;
typedef struct
{
RedType r[11];
int length;
}SqList;
void InsertSort (SqList *L,int n)
{
int *c=new int[11];
int i,j;
RedType tmp = L->r[1];
//计算c[i]
for(i =1;i<L->length;i++)
{
for( j=2;j<L->length;j++)
{
if (L->r[i].key<L->r[j].key)
{
c[i]++;
}
}
}
//按C[i]排序
for(i = L->length;i>1;i++)
{
for(int j=1;j<L->length;j++)
{
if (c[i]<c[j])
{
tmp = L->r[j];
L->r[i] = L->r[j];
L->r[j] = tmp;
}
}
}
delete[] c;
}
int main(void)
{
system("pause");
return 0;
}