-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1991.cpp
More file actions
48 lines (43 loc) · 773 Bytes
/
Copy path1991.cpp
File metadata and controls
48 lines (43 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
int v[26][2];
void first(int n){
if (n==-1)
return;
cout << (char)(n+65);
first(v[n][0]);
first(v[n][1]);
}
void second(int n){
if (n==-1)
return;
second(v[n][0]);
cout << (char)(n+65);
second(v[n][1]);
}
void third(int n){
if (n==-1)
return;
third(v[n][0]);
third(v[n][1]);
cout << (char)(n+65);
}
int main(){
int n; cin>>n;
for (int i=0; i<n;i++){
char a,b,c; cin >>a>>b>>c;
if(b=='.')
v[a-65][0]=-1;
else
v[a-65][0]=b-65;
if(c=='.')
v[a-65][1]=-1;
else
v[a-65][1]=c-65;
}
first(0);
cout << "\n";
second(0);
cout << "\n";
third(0);
}