-
Notifications
You must be signed in to change notification settings - Fork 0
[스택, 큐, 덱] 8월 27일 #3
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 ### 기존 제출: 1158, 10757, 4949
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.
[스택, 큐, 덱 이론 문제 코드 리뷰 완료]
4949(P2)
수아님 안녕하세요! 과제하시느라 수고 많으셨습니다! 🥰
함수 분리도 좋고, 주석도 굉장히 꼼꼼하게 작성해주셔서 이해하기 쉬웠습니다! 💯
몇 가지 코멘트 드렸습니다.
궁금한 점이 있다면 리뷰어를 호출해주세요!
using namespace std; | ||
|
||
// 문자열 s가 괄호 균형을 이루는지 확인하는 함수 | ||
bool isBalanced(const string& s) { |
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.
함수화 너무 좋습니다🥰🥰🥰
switch (ch) { | ||
case '(': case '[': // 열린 (대)괄호일 때는 스택에 추가한다. | ||
stk.push(ch); | ||
break; | ||
case ')': | ||
// 닫힌 괄호일 때는 | ||
if (stk.empty() || stk.top() != '(') return false; // 스택이 비어있거나 올바른 짝이 아닐 경우 false(불균형)을 리턴한다. | ||
stk.pop(); // 올바른 짝이면 스택에서 제거한다. | ||
break; | ||
case ']': | ||
// 닫힌 대괄호일 때는 | ||
if (stk.empty() || stk.top() != '[') return false; // 스택이 비어있거나 올바른 짝이 아닐 경우 false(불균형)을 리턴한다. | ||
stk.pop(); // 올바른 짝이면 스택에서 제거한다. | ||
break; | ||
default: | ||
// 괄호가 아닌 다른 문자는 무시한다. | ||
break; | ||
} | ||
} | ||
|
||
// 모든 괄호가 닫히고 스택이 비어있다면 균형 잡힌 것이다. | ||
return stk.empty(); |
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.
switch문으로 작성해주셨네요🤗 스택에 넣고 빼는 경우의 수 잘 분리해주셨습니다! 리턴 시점과 값도 좋아요👍👍
|
||
//getline은 cin >> 처럼 공백이나 개행문자에서 입력을 끊지 않고 개행문자까지 포함한 전체의 줄을 읽기 때문에 훨씬 효율적이다. | ||
while (getline(cin, line)) { // 입력을 한 줄씩 읽는다. | ||
if (line == ".") break; // 입력이 "."이면 종료한다. |
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. 중괄호가 없으면 코드를 수정할 일이 생길 때 불편할 수 있어요. 특히, 협업할 때는 나중에 추가한 중괄호로 인해 git에서 충돌이 날 수 있답니다...!! 😱 코드가 한 줄이더라도 중괄호 넣으시는 걸 권장드립니다👍
int main() { | ||
string line; // 입력 문자열을 저장할 변수 | ||
|
||
//getline은 cin >> 처럼 공백이나 개행문자에서 입력을 끊지 않고 개행문자까지 포함한 전체의 줄을 읽기 때문에 훨씬 효율적이다. |
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.
[스택, 큐, 덱 구현 코드리뷰 완료]
1158(P2)
코드 리뷰 완료하였습니다 !
주석이 있어서 코드 리뷰하는데 도움이 되었습니다 ㅎㅎ
몇 가지 사소한 코멘트 남겼으니 확인해주세요 😊
cin >> N >> K; | ||
|
||
// 요세푸스 순열 계산 | ||
vector<int> number = getNumber(N, K); |
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.
함수 따로 빼둔 거 너무 좋습니다 !!
} | ||
|
||
int main() { | ||
int N, K; |
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.
P3
전역상수가 아닌 변수명은 대문자 사용을 지양하고 있습니다.
n, k 로 변경해주시면 좋을 것 같습니다 !
@@ -0,0 +1,51 @@ | |||
#include <iostream> | |||
#include <list> // 원형 큐를 구현하기 쉬워서 list 함수를 사용 |
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
c++에는 queue 자료구조가 구현되어 있습니다 ! 수업시간에 배운 queue를 사용하면 더 좋을 것 같습니다 ㅎㅎ
인적사항
이름: 조수아
학번: 2371060
기존 제출:
1158, 10757, 4949