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

📄 emp6_10.cpp

📁 该包是数据结构的实验软件,来源于合肥工业大学人工智能与数据挖掘实验室,用来实现数据结构.
💻 CPP
字号:
// emp6_10}
#include "trees.h"

tptrlink ptr;
int high(tree t)
{
	int h,hight;
	tree t1;
	if (t==NULL) hight=0;
	else{
		t1=t->firstson; 
		h=0;
        while (t1!=NULL){
        	h=Max(h, high(t1));
        	t1=t1->nextbrother;
        }
        hight=h+1;
        tptr_point_to(ptr, t);
        dispint_attnode_angle(h+1,t,150);
        getch();
    }
    return hight;
}

int leaf(tree t)
{
	int l,leaft;
	tree t1;
	if (t==NULL) leaft=0;
	else{
		if (t->firstson==NULL) l=1;
		else{
			l=0;
			t1=t->firstson;
			while (t1!=NULL){
				l=l+leaf(t1);
			    t1=t1->nextbrother;
			}
		}
        leaft=l;
        tptr_point_to(ptr, t);
        dispint_attnode_angle(l,t,270);
        getch();
   }
   return leaft;
}

void main()
{
	tree t;
    int k;
    
    get_tree(t);
    create_tptr(ptr, "T");
    printf("high=%d\n",high(t));
    getch();
    printf("leaf=%d\n",leaf(t));
    getch();
}

⌨️ 快捷键说明

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