Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
숨바꼭질 4
기존의 숨바꼭질 문제와 비슷하지만 이동 경로를 출력해야 한다는 점이 다르다.
나는 무엇을 할 수 있게 되었는가?
n
에서m
으로 가는 정점의 순서를 출력하는 재귀 함수 작성을 할 수 있게 되었다.이 문제에서
int from[MAX]
는from[i] 는 i 정점으로 오기 전 정점
값을 갖는다.문제의 예시처럼
5 -> 17
의 경우from
은 다음과 같은 값을 갖는다.따라서 역순으로 출력해야 하기 때문에 재귀는 다음과 같다.
만약 거꾸로 된 상태 그대로 출력하겠다면
for
문으로 간단하게 출력할 수 있다.만약 이동경로를 저장하고 이를 거꾸로 출력한다면 이렇게 하자.