양혜림/4주차#10
Open
hyellm wants to merge 1 commit into
Open
Conversation
[4주차] 3진법 뒤집기 / Lv. 1 https://school.programmers.co.kr/learn/courses/30/lessons/68935 [4주차] 같은 숫자는 싫어 / Lv. 1 https://school.programmers.co.kr/learn/courses/30/lessons/12906
YEOUL0520
reviewed
Oct 9, 2024
| int p = 0; | ||
| int arr_size = arr.size(); | ||
|
|
||
| answer.resize(arr_size); // answer의 크기를 arr의 크기로 설정 |
Owner
There was a problem hiding this comment.
resize 쓰는거 신기한데? 스터디 할때 어떻게 동작하는 함수인지 설명해주면 좋을 것 같음!
YEOUL0520
reviewed
Oct 9, 2024
| #include <math.h> // pow() | ||
|
|
||
| int solution(int n) { | ||
| int* arr = (int*)malloc(n * sizeof(int)); // 동적 배열 할당 :: int arr[100]; |
Owner
There was a problem hiding this comment.
오랜만에 보는 동적배열,, 저도 이 방법을 사용하엿는데요,(ㅋㅋ
YEOUL0520
reviewed
Oct 9, 2024
| int i = 0, cal = 0, answer = 0; | ||
|
|
||
| // 3진수 계산 | ||
| while (n >= 3) { |
Owner
There was a problem hiding this comment.
n != 0 이 조건 쓰면 변환 후 마지막 자리값을 따로 넘겨줄 필요 없을 것 같음!
sseoh47
reviewed
Oct 10, 2024
| int p = 0; | ||
| int arr_size = arr.size(); | ||
|
|
||
| answer.resize(arr_size); // answer의 크기를 arr의 크기로 설정 |
There was a problem hiding this comment.
resize 신기해요. answer 초기화할때 크기 지정하면 안써도 되나요?
sseoh47
reviewed
Oct 10, 2024
| arr[i] = n; // 변환 후의 마지막 자리값 넘겨주기 | ||
|
|
||
| // 반전시키지 않아도 거꾸로 들어있으므로 그대로 10진법 변환 | ||
| for (; i >= 0; i--) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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주차] 3진법 뒤집기 (68935) / Lv. 1
https://school.programmers.co.kr/learn/courses/30/lessons/68935
[4주차] 같은 숫자는 싫어 (12906) / Lv. 1
https://school.programmers.co.kr/learn/courses/30/lessons/12906