#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <malloc.h>
#define maxlen 30
typedef struct Node
{
struct Node * leftChild;
struct Node * rightChild;
int key;
}Node;
Node *initTree()
{
int n = 0;
scanf("%d",&n);
if(0 == n){
return NULL;
}
Node *p = (Node *)malloc(sizeof(Node));
p->key = n;
p->leftChild = initTree();
p->rightChild = initTree();
return p;
}
void preOrderRecursive(Node *root)
{
if(root){
printf("%d\n",root->key);
preOrderRecursive(root->leftChild);
preOrderRecursive(root->rightChild);
}
}
int getResult(Node *pTree)
{
Node *queue[maxlen];
int front = 0;
int rear = 0;
int count = 0;
queue[(++rear)%maxlen] = pTree;
int last = 1;
while(front != rear){
Node *tmp = queue[(++front)%maxlen];
if(tmp->leftChild == NULL && tm
求二叉树最浅叶子结点们的和
最新推荐文章于 2025-05-28 09:55:38 发布