week2 17478 재귀함수가 뭔가요 김다운 #38
Open
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.
어려워보이지 않았는데도 미묘하게 틀리는 부분들이 많아서 출력도 많이 해보고 시행착오도 많이 겪었다.
문장이 길어지는게 싫어서 줄바뀜으로 구분되는 각 문장을 전역변수
text1,text2, ...,text6으로 미리 나누어서 선언해두었다. 코드가 짧아지지만 다른 사람이 보기에 가독성은 안 좋아보일수도 있을 것 같다.marks변수로 재귀되는 문장 앞의 underbar의 길이를 조정한다.text1 = '"재귀함수가 뭔가요?"'에서text4 = '그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어."'까지가 underbar가 늘어나면서 붙는 구간이다. 그래서8~14줄에 이를 구현했다.재귀를 반복하다가 멈출 때
text1질문 한 번 더 던져주고 답변 부분인text5,text6를 출력했다. 답변은 한 번만 나오면 되므로if num==0일 때 마지막 반환 조건문에 작성했다.text6을marks가 4개 단위로 사라질 때까지 출력해야되므로 재귀되는 함수 아래16~18줄에 이를 구현했다.