Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dohyeondol1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
| 3μ°¨μ‹œ | 2025.03.24 | κ·Έλž˜ν”„ 탐색 | [λ°”μ΄λŸ¬μŠ€](https://www.acmicpc.net/problem/2606)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/10|
| 4μ°¨μ‹œ | 2025.03.28 | BFS | [점프왕 쩰리 (Large)](https://www.acmicpc.net/problem/16174)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/15|
| 5μ°¨μ‹œ | 2025.04.02 | DFS & BFS | [DFS와 BFS](https://www.acmicpc.net/problem/1260)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/18|
| 6μ°¨μ‹œ | 2025.04.05 | DP | [ν‰λ²”ν•œ λ°°λ‚­](https://www.acmicpc.net/problem/12865)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/22|
| 7μ°¨μ‹œ | 2025.04.08 | 트리 | [트리 순회](https://www.acmicpc.net/problem/1991)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/26|
---
50 changes: 50 additions & 0 deletions dohyeondol1/트리/7-dohyeondol1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
using namespace std;
pair<char,char> node[26];
int N;

//μ „μœ„μˆœνšŒ
void preorder(char current){
if(current == '.')
return;

cout << current;
preorder(node[current-'A'].first);
preorder(node[current-'A'].second);
}

//μ€‘μœ„μˆœνšŒ
void inorder(char current){
if(current == '.')
return;

inorder(node[current-'A'].first);
cout << current;
inorder(node[current-'A'].second);
}

//ν›„μœ„μˆœνšŒ
void postorder(char current){
if(current == '.')
return;

postorder(node[current-'A'].first);
postorder(node[current-'A'].second);
cout << current;
}

int main(){
cin >> N;
for(int i = 0; i < N; i++){
char parent, left, right;
cin >> parent >> left >> right;
node[parent-'A'].first = left;
node[parent-'A'].second = right;
}

preorder('A');
cout << "\n";
inorder('A');
cout << "\n";
postorder('A');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0 λΉ μ‘Œμ–΄μš” γ…Žγ…Ž

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ•„ λ§žλ‹€! γ…‹γ…‹γ…‹γ…‹
덕뢄에 return 0 μ•ˆμΌλŠ”λ°λ„ μ™œ λŒμ•„κ°€λŠ”μ§€μ— λŒ€ν•΄μ„œ μ°Ύμ•„λ΄€μŠ΅λ‹ˆλ‹€...γ…Ž

return 0은 ν”„λ‘œκ·Έλž¨μ΄ μ •μƒμ μœΌλ‘œ 잘 μ’…λ£Œλ˜μ—ˆμŒμ„ μš΄μ˜μ²΄μ œμ— μ•Œλ¦¬κΈ° μœ„ν•¨μΈλ°,
CλŠ” C99 μ΄ν›„λ‘œ, C++은 C++11μ΄ν›„λ‘œ λͺ…μ‹œμ μœΌλ‘œ return 0을 μž‘μ„±ν•˜μ§€ μ•Šμ•„λ„ μ•Œμ•„μ„œ mainμ—μ„œ 0을 λ°˜ν™˜ν•˜κ²Œ λ˜μ—ˆλ‹€λ„€μš”!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ§žμ•„μš” γ…Žγ…Ž λ°±μ€€μ—μ„œ void main이 μ•ˆ λ˜λŠ” μ΄μœ λ„ 같은 μ΄μœ μž…λ‹ˆλ‹€

}