求调,编译错误,
查看原帖
求调,编译错误,
1198506
wo488楼主2024/10/13 08:08
#include<assert.h>
#define N 100001
struct tree {
	int l;
	int r;
};

int getdepth(tree *s,int index) {
	int left, right;
	if (s[index].l == 0 ||s[index].r == 0)
	{
		return 1;
	}
	else {
		left = getdepth(s,s[index].l);
		right = getdepth(s,s[index].r);
		return left > right ? (left + 1) : (right + 1);
	}

}


int main() {
	int n;
	int t=0;
	scanf("%d", &n);
	struct tree s[N];
	
	
	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &s[i].l,&s[i].r);
	}
	if (n == 0) {
		t = 0;

	 }
	else
	 t = getdepth(s,1);
	printf("%d", t);

}
2024/10/13 08:08
加载中...