void Transmatrix(matrix sample)
{
int psample, ptemp, col;
int* cnum, * cpos;
node temp;
temp = (node)calloc(sample->num, sizeof(struct Node));
cnum = (int*)calloc(sample->r + 1, sizeof(int));
cpos = (int*)calloc(sample->r + 1, sizeof(int));
for (psample = 0; psample < sample->num; psample++) {
cnum[sample->front[psample].r]++;
}
for (col = 1; col <= sample->r; col++) {
cpos[col] = cpos[col - 1] + cnum[col - 1];
}
for (psample = 0; psample < sample->num; psample++) {
col = sample->front[psample].r;
ptemp = cpos[col];
temp[ptemp].data = sample->front[psample].data;
temp[ptemp].l = sample->front[psample].r;
temp[ptemp].r = sample->front[psample].l;
cpos[ptemp]++;
}
free(sample->front);
sample->front = temp;
free(cpos); //出错
free(cnum);
}