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

📄 sub14.cpp

📁 STRUCTURI DE DATE SI ALGORITMI
💻 CPP
字号:
#include"arboreb.cpp"

void postordine(Nod*& N);
int adinc(Nod*& N);
int testcaut(Nod*& N);

void main()
{
Nod *rad;
clrscr();
rad=creareArbore();
printf("\nArborele parcurs in postordine : ");
postordine(rad);
printf("\nAdincimea este : %d",adinc(rad));
printf("\nArborele este de cautare :");
if(testcaut(rad)==1)
	printf("DA");
else
	printf("NU");
getch();
}

void postordine(Nod*& N)
{
if(N->data!=0)
	{
	postordine(N->stg);
	postordine(N->drt);
	printf(" %c",N->data);
	}
}


int max=1;
int t=1;

int adinc(Nod *& N)
{
while(N->data!=0)
	{
	if(N->stg!=0)
		{
		t++;
		adinc(N->stg);
		if(t>max)
			max=t;
		}
	else
		if(N->drt!=0)
			{
			t++;
			adinc(N->drt);
			if(t>max)
				max=t;
			}
       return(max);
	}
}

int testcaut(Nod*& N)
{
while(N->data!=0)
	{
	if(N->stg->data<N->data && N->drt->data>N->data)
		{
		testcaut(N->stg);
		testcaut(N->drt);
		}
	else
		return(0);
	return(1);
	}
}

⌨️ 快捷键说明

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