谁看看我的构造随机二叉树怎么写挂了
  • 板块灌水区
  • 楼主shy_lihui
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/10/8 22:02
  • 上次更新2024/10/9 12:01:12
查看原帖
谁看看我的构造随机二叉树怎么写挂了
1053122
shy_lihui楼主2024/10/8 22:02
struct node
{
	int l,r;
}s[10005];

void make_tree(int root)
{
	if(s[root].l==0 && s[root].r==0)
	{
		return;
	}
	s[root].l=(1+rand()%root);
	s[root].r=(root+1+rand()%root);
	if(s[root].l!=0)
	{
		make_tree(s[root].l);
	}
	if(s[root].r!=0)
	{
		make_tree(s[root].r);
	}
}
2024/10/8 22:02
加载中...