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

📄 7-8.c

📁 本人收集的一些数据结构经典算法实现
💻 C
字号:
#include "stdio.h"
#define MAX_TREES 10
typedef struct datatype
{
	int D; /* 叶节点的衰减量*/
	int d; /* 父节点的衰减量*/
	int  boost; /*当且仅当本处设置放大器,则boost为1*/
}Data;
typedef struct 	Tree_node{
       Data data;
       struct Tree_node *lchild,*rchild;
}Tree;
/* 计算* x .处的衰减量,如果衰减量超出了容忍值,则设置放大器
信号调节器位于阴影节点节点内的数字为D值*/
void SetBoosters(Tree *x,int tolerance)
{
	Tree *y = x->lchild;
	int degradation;
	x->data.D = 0; /* 初始化x的衰减量*/
	if (y) 
	{/* 从左孩子来计算*/
		degradation = y->data.D + y->data.d;
		if (degradation > tolerance)
		{
			y->data.boost = 1;
			return ; 
		}
		else 
			x->data.D = degradation;
	}
	y = x->rchild;
	if (y) 
	{/* 从右孩子来计算*/
		degradation = y->data.D + y->data.d;
		if (degradation > tolerance)
			y->data.boost = 1;
		else if (x->data.D < degradation)
			x->data.D = degradation;
	}
}

void main()
{
	Tree *x;
	int to=1;
	SetBoosters(x,to);
}

⌨️ 快捷键说明

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