文档介绍:逆位序正位序
// algo2- 、
#include""typedef int ElemType;#include"c2-"#include"bo2-"
void ;++col)num[col]=0;
for(t=1;t<=;++t) ++num[[t].j];
cpot[1]=1; for (col=2;col<=;++col) cpot[col]=cpot[col-1]+num[col-1];
for(p=1;p<=; ++p){ col=[p].j; q=cpot[col]; [q].i=[p].j; [q].j=[p].i; [q].e=[p].e; ++cpot[col]; }}
free(num);
free(cpot);
return OK;
}
矩阵
void main()
{
TSMatrix A,B;
printf("创建矩阵A: ");
CreateSMatrix(A);
PrintSMatrix(A);
//FastTransposeSMatrix(A,B);
printf("矩阵B(A的快速转置): ");
//PrintSMatrix(B);
DestroySMatrix(A);
// DestroySMatrix(B);
}
求结点个数和深度
#include <>#include <iostream>typedef struct BiTNode {
char data;BiTNode *lchild,*rchild; // 左右孩子指针}BiTNode,*BiTree;
void CreatBiTree(BiTree &T){char ch;scanf("%c",&ch);if(ch==' ') T=NULL;
else {if(!(T=(BiTNode *)malloc(sizeof(BiTNode)))) exit(-1);T->data=ch;
CreatBiTree(T->lchild);CreatBiTree(T->rchild);} }
int countc(BiTree T) { //返回以T结点为根的子树的结点个数
if (T==NULL) return 0;return 1+countc(T->lchild)+countc(T->rchild);}
int Depth(BiTree T){int depthval,depthLeft,depthRight; if(!T) depthval=0;
else {depthLeft = Depth(T->lchild);depthRight= Depth(T->rchild);
depthval = 1 + (depthLeft > depthRight ?depthLeft : depthRight) ;
}
return depthval;}
int main(vo