⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bit.h

📁 本文当为二叉树的演示程序
💻 H
字号:
#include "malloc.h"
#include "stdlib.h"
struct bitnode tree[];
typedef struct bitnode
{
	char data;
	struct bitnode *left;
	struct bitnode *right;
}bitree;

bitree *creat(){
bitree *w;
 char ch;
 ch=getchar();
 if(ch=='\n') return 0;
else{
  w=(bitree *)malloc(sizeof(bitree));
  w->data=ch;
  w->left=creat();
  w->right=creat();
 }
 ch='\0';
 return w;
}


void PreOrder(bitree *t)
{	
	if(t!=NULL) 

	{
		printf("%c",t->data);


		PreOrder(t->left);


		PreOrder(t->right);
	} 
};

void MidOrder(bitree *t)
{
if(t!=NULL)
{	MidOrder(t->left);
	printf("%c",t->data);
	MidOrder(t->right);
}
};

void PostOrder(bitree *t)
{if(t!=NULL)
{	PostOrder(t->left);
	PostOrder(t->right);
	printf("%c",t->data);
}
};

 EmptyBitree(bitree *t)
{
if(t==NULL)
{
	printf("yes");
}
else printf("no");

}

int Depth(bitree *t)
{	int depth1,depth2;
	
if(t=NULL)
return 0;
else {
depth1=Depth(t->left);
depth2=Depth(t->right);
if(depth1>depth2)
 return (depth1+1);
else return (depth2+1);
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -