-
Notifications
You must be signed in to change notification settings - Fork 0
[동적 계획법] 10월 1일 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
### 인적사항 이름: 조수아 학번: 2371060 ### 과제 제출 기존 제출: 2579, 11053, 20923
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[동적계획법 코드리뷰 완료]
2579(P2)
코드 리뷰 완료하였습니다 !
주석이 있어서 코드 리뷰하는데 도움이 되었습니다 ㅎㅎ
몇 가지 사소한 코멘트 남겼으니 확인해주세요 😊
int stepScores[MAX]; //각 계단의 점수 | ||
int maxScores[MAX]; //각 계단까지의 최대 점수를 저장하는 배열 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2
벡터 선언시에 n개 또는 n+1개만큼만 선언해준다면 메모리 측면에서 더욱 효율적인 코드가 될 것 같습니다 !
|
||
|
||
//최대 점수를 계산하는 함수 | ||
void calculateMaxScore() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 따로 빼둔 거 너무 좋습니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11053, 20923 두 문제 너무 잘 풀어주셨습니다! 사소한 코멘트 남겨드렸으니 참고해주시면 감사할 것 같아요~ 수고하셨습니다!!
int getMax(int a, int b) { //두 수 중 더 큰 값을 반환하는 함수 | ||
return (a > b) ? a : b; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최대값을 반환하는 함수는 C++에 구현되어 있는 함수를 써주시면 좋을 것 같아요!
deque<int> doGround; //도도의 카드 | ||
deque<int> suGround; //수연의 카드 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deque 자료구조를 적절히 잘 사용해주셨네요!
} | ||
|
||
string winner = ""; //승자 | ||
playGame(dodo, suyeon, m, winner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수화 좋습니다!
if (!doGround.empty() && !suGround.empty() && doGround.back() + suGround.back() == 5) { | ||
while (!doGround.empty()) { | ||
suyeon.push_front(doGround.front()); | ||
doGround.pop_front(); | ||
} | ||
while (!suGround.empty()) { | ||
suyeon.push_front(suGround.front()); | ||
suGround.pop_front(); | ||
} | ||
} | ||
else if ((!doGround.empty() && doGround.back() == 5) || (!suGround.empty() && suGround.back() == 5)) { | ||
while (!suGround.empty()) { | ||
dodo.push_front(suGround.front()); | ||
suGround.pop_front(); | ||
} | ||
while (!doGround.empty()) { | ||
dodo.push_front(doGround.front()); | ||
doGround.pop_front(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비슷한 행위를 하는 코드가 반복적으로 쓰여져 있는 것을 확인할 수 있네요. 함수로 따로 뺴주시면 좋을 것 같아요!
if (isDodoTurn) { | ||
doGround.push_back(dodo.back()); | ||
dodo.pop_back(); | ||
} else { | ||
suGround.push_back(suyeon.back()); | ||
suyeon.pop_back(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비슷한 행위를 하는 코드가 반복적으로 쓰여져 있는 것을 확인할 수 있네요. 함수로 따로 뺴주시면 좋을 것 같아요!
인적사항
이름: 조수아
학번: 2371060
과제 제출
기존 제출: 2579, 11053, 20923