Conversation
sforseohn
reviewed
Sep 2, 2024
| cout << "yes" << endl; | ||
| else | ||
| cout << "no" << endl; | ||
| cout << '\n'; |
Member
There was a problem hiding this comment.
P1. 이미 endl로 줄바꿈 문자를 출력했기 때문에 또다시 출력해줄 필요가 없어요! 코딩 테스트에서는 출력 형식이 조금만 달라도 틀렸다고 처리되기 때문에 수정하시면 좋을 것 같아요🤗🤗
Comment on lines
+7
to
+46
| int main() | ||
| { | ||
| while(1) { | ||
| stack <char> s; | ||
| string str; | ||
| getline(cin, str); | ||
|
|
||
| if (str == ".") | ||
| return 0; | ||
|
|
||
| bool flag = true; | ||
| for (int i = 0; i < str.length(); i++) { | ||
| if (str[i] == '(' || str[i] == '[') | ||
| s.push(str[i]); | ||
| else if (str[i]== ')') { | ||
| if (!s.empty()&&s.top()=='(') | ||
| s.pop(); | ||
| else { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } | ||
| else if (str[i]==']'){ | ||
| if(!s.empty()&& s.top()=='[') | ||
| s.pop(); | ||
| else | ||
| { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (flag && s.empty()) | ||
| cout << "yes" << endl; | ||
| else | ||
| cout << "no" << endl; | ||
| cout << '\n'; | ||
| } | ||
| return 0; | ||
| } No newline at end of file |
Member
There was a problem hiding this comment.
P2. 현재 메인함수에서 많은 기능을 처리하고 있어요. 주요 기능을 함수화해두면 다른 곳에서도 재사용할 수 있답니다! 괄호의 대칭을 확인하는 별도의 함수를 만들고 메인함수는 이 함수를 호출하여 결과만 출력하도록 만들어볼까요? 🥰🥰
Comment on lines
+14
to
+15
| if (str == ".") | ||
| return 0; |
Member
There was a problem hiding this comment.
P2. 중괄호가 없으면 코드를 수정할 일이 생길 때 불편할 수 있어요. 특히, 협업할 때는 나중에 추가한 중괄호로 인해 git에서 충돌이 날 수 있답니다...!! 😱 코드가 한 줄이더라도 중괄호 넣으시는 걸 권장드립니다👍
Comment on lines
+19
to
+37
| if (str[i] == '(' || str[i] == '[') | ||
| s.push(str[i]); | ||
| else if (str[i]== ')') { | ||
| if (!s.empty()&&s.top()=='(') | ||
| s.pop(); | ||
| else { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } | ||
| else if (str[i]==']'){ | ||
| if(!s.empty()&& s.top()=='[') | ||
| s.pop(); | ||
| else | ||
| { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } |
Comment on lines
+19
to
+29
| if (str[i] == '(' || str[i] == '[') | ||
| s.push(str[i]); | ||
| else if (str[i]== ')') { | ||
| if (!s.empty()&&s.top()=='(') | ||
| s.pop(); | ||
| else { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } | ||
| else if (str[i]==']'){ |
Member
There was a problem hiding this comment.
P2. i번째 문자 값이 반복적으로 사용되고 있네요! 변수로 만들면 코드 가독성을 높일 수 있을 것 같아요🤗🤗
flowing1ife
requested changes
Sep 2, 2024
flowing1ife
left a comment
There was a problem hiding this comment.
[스택, 큐, 덱 구현 코드리뷰 완료]
1158(P1)
안녕하세요 ! 백준에서 코드를 돌리니 틀렸다고 나옵니다😭
다시 한 번 확인해주시고 리뷰어 호출해주세요 !
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.
인적사항
학번: 2317014
이름: 박나림
과제 제출
기존 제출:
추가 제출: