C TEST
There is a tree of nodes,each node contains a random interger number and a block of memory of random size.
树的每个节点包含一个随机整形数和一块随机大小的内存;
The number of child nodes for any parent is random,and the depth of the tree is also a random number.
每个父节点的子节点个数都是随机的,树的深度也是随机数值;
All the random numbers should be generated by random( ).
所有的随机数值使用random函数生成;
TASKS:
1. Create a tree of this kind.
创建一个这种类型的树结构;
2. Exam the tree,if a parent node and his child node both contain odd numbers,then insert a node containing an even number
检测这个树,如果父节点和他的子节点中的整形数均是奇数,那么插入一个节点;
between the parent node and the child node.The inserted node may have only 1 child node.
此节点中的整形数为偶数,插入位置在父节点与子节点中间,且包含一个子节点;
3. Traverse the tree, and print the number of each node.
遍历这棵树的所有节点,打印出每个节点中的整形数;
4. Delete the tree and free the memory.
删除这棵树并且释放存储空间,即内存;
-------------------------------------------------------------------------------------------------------------------------------
节点结构:
#include<stdio.h>
#include<stdlib.h>
</pre><pre name="code" class="cpp">typedef struct PTree
{
int test_number;
char *test_pointer; //此处的申请空间有无问题,有malloc就应该有free,但可以释放结构实例
}PTree_s;