2011年11月16日

遍历二叉树的基本运算

摘要: /*3. 完成对二叉树的二叉链表结构的定义。 并编写算法生成一棵二叉树, 以及编写二叉树的先序遍历、中序遍历、后序遍历算法, 并且验证各算法功能已实现。*/ #include<iostream> using namespace std; typedef char datatype; typedef struct node *pointer; //结点指针类型 struct node //结点类型 { datatype data; pointer lchild,rchild; }; typedef pointer bitree; /... 阅读全文

posted @ 2011-11-16 09:34 1.曲待续 阅读(365) 评论(0) 推荐(0) 编辑

对三角矩阵进行压缩存储为一维数组

摘要: /*1. 已知矩阵A[5][5]是一个下三角矩阵,如下图 要求编写算法把矩阵A采用压缩存储,存储到一维数组B[16]中, 并且依次输出B中各元素的值以验证该算法功能已实现 */ #include<iostream> using namespace std; const int m=5; const int n=5; const int c=16; int B[c]; //定义一维数组B[16],长度为16 //初始化数组A[5][5] int A[m][n]={{1},{4,7},{6,9,5},{1,8,4,1},{2,3,0,9,6}}; int main(... 阅读全文

posted @ 2011-11-16 09:32 1.曲待续 阅读(1267) 评论(0) 推荐(0) 编辑

导航