Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
883 B
5
Indexable
#include <iostream>
using namespace std;
int N;
int Firstchild[101], Secondchild[101];
char Alpha[101];
char Answer[101];
void in( int F[],int S[], char A[],int i)
{
	if(A[i]=='\0') return ;
	in( F,S,A,F[i]);
	cout<<A[i];
	in(F,S,A,S[i]);
}

int main()
{
	//freopen("text.txt","r",stdin);
	int test_case;
	for(test_case = 1; test_case <= 10; ++test_case)
	{
		int i;
		


		cin >> N;
		for(i=0;i<N;i++)
		{
			Firstchild[i]=0;
			Secondchild[i]=0;
			Alpha[i]=0;
			Answer[i]=0;
		}

		for(i = 0; i < N; i++)
		{
			int addr;
			char buf[100];

			cin >> addr;
			cin >> buf;

			Alpha[addr] = buf[0];

			if(addr*2 <= N)
			{
				cin >> Firstchild[addr];
				if(addr*2 + 1 <= N)
					cin>>Secondchild[addr];
			}
		}

		cout << "#" << test_case << " ";
		in(Firstchild,Secondchild,Alpha,1);
		cout<<endl;

	}

	return 0;
}