1

噢莫加纳加加加 · 发布于 2024-05-05 · 浏览 503 回复 0
#include<iostream>

using namespace std;

int res=0;

void tree(int t,bool isLeftSon)
{
	int left,right;
	cin>>left;
	if(left!=-1)
		tree(left,1);
	cin>>right;
	if(right!=-1)
		tree(right,0);
	if(left==-1&&right==-1&&isLeftSon)
		res+=t;
	return;
}

int main()
{
	int t;
	cin>>t;
	tree(t,0);
	cout<<res;
	return 0;
}

全部回复 共 0 条

还没有人回复。往下写第一条。

发表回复