Skip to content

Commit

Permalink
Merge pull request #55 from AlgoLeadMe/18-YIM2UL2ET
Browse files Browse the repository at this point in the history
18-YIM2UL2ET
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents 5e62857 + cd98166 commit bbde794
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
| 15์ฐจ์‹œ | 2024.04.09 | ๊ตฌํ˜„ | [BOJ 14719](https://www.acmicpc.net/problem/14719) | [BOJ 14719 ํ’€์ด](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/48) |
| 16์ฐจ์‹œ | 2024.04.11 | ์• ๋“œ ํ˜น | [BOJ 15927](https://www.acmicpc.net/problem/15927) | [BOJ 15927 ํ’€์ด](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/51) |
| 17์ฐจ์‹œ | 2024.04.15 | DP | [BOJ 11726](https://www.acmicpc.net/problem/11726) | [BOJ 11726 ํ’€์ด](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/53) |

| 18์ฐจ์‹œ | 2024.04.15 | ํŠธ๋ฆฌ | [BOJ 5639](https://www.acmicpc.net/problem/5639) | [BOJ 5639 ํ’€์ด](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/53) |
---
34 changes: 34 additions & 0 deletions YIM2UL2ET/ํŠธ๋ฆฌ/18์ฐจ์‹œ - BOJ 5639.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
using namespace std;

struct node {
int value = -1;
node* right = NULL;
node* left = NULL;
};

void input(node &nd, int n) {
if (nd.value == -1) nd.value = n;
else if (nd.value > n) {
if (nd.left == NULL) nd.left = new node;
input(*nd.left, n);
}
else {
if (nd.right == NULL) nd.right = new node;
input(*nd.right, n);
}
}

void output(node &nd) {
if (nd.left != NULL) output(*nd.left);
if (nd.right != NULL) output(*nd.right);
cout << nd.value << '\n';
}

int main(void) {
int n;
node root;
while (cin >> n) input(root, n);
output(root);
return 0;
}

0 comments on commit bbde794

Please sign in to comment.