emp5_16.cpp

来自「该包是数据结构的实验软件,来源于合肥工业大学人工智能与数据挖掘实验室,用来实现数」· C++ 代码 · 共 70 行

CPP
70
字号
// emp5_16 
#include "btrechar.h"

bptrlink ptr;
int n,n1;
void nodes1(bitre t)
{
	int n1;
	if (t==NULL)  n=0;
	else{
		nodes1(t->lchild);
		n1=n;
		nodes1(t->rchild);
		n=n+1+n1;
		bptr_point_to(ptr, t);
		getch();
		dispint_atbnode_angle(n,t,0);
	}
}

void nodes2(bitre t)
{
	if (t==NULL)  n=0;        //{ Wrong }
	else{
		nodes2(t->lchild);
		n1=n;
		n=n+1+n1;
		bptr_point_to(ptr, t);
		getch();
		dispint_atbnode_angle(n,t,0);
		nodes2(t->rchild);
	}
}

void nodes3(bitre t)
{
	if (t==NULL)      ;   //n=0;         //{ Correct }
	else{
		nodes3(t->lchild);
		n=n+1;
		bptr_point_to(ptr,t);
		getch();
		dispint_atbnode_angle(n,t,0);
		nodes3(t->rchild);
	}
}

void main()
{
	bitre t;
	int k;
		initial_bitre();
	load_bitre_file(t,"bitres\\full42.cbt");
	comput_bitre_card(t);
	window(1,1,80,4);
	create_bptr(ptr, "T");
	disp_bitre("Preorder",t);
	n=0;
	nodes1(t);
	printf("nodes1=%d\n",n);
	disp_bitre("Preorder",t);
	n=0;
	nodes2(t);
	printf("nodes2=%d\n",n);
	disp_bitre("Preorder",t);
	n=0;
	nodes3(t);
	printf("nodes3=%d\n",n);
	getch();
}

⌨️ 快捷键说明

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