这个对不对呢?
#define maxNodes 15 void createCSTree_Degree(CSTree &T, DataType e[], int degree[], int n) { //e层序序列,degree结点的度,n结点的个数 CSNode *pointer = new CSNode[maxNodes]; int i, j, d, k=0; for (int i = 0; i < n; i++) { pointer[i] = new CSNode; pointer[i].data = e[i]; pointer[i].firstchild = pointer[i].nextsibling = NULL; } for (int i = 0; i < n; i++) { d = degree[i]; if (d) { k++; pointer[i]->firstchild = pointer[k]; for (j = 2; j <= d; j++) { pointer[j - 1]->nextsibling = pointer[j]; } } } T = pointer[0]; delete[]pointer; }