-
Notifications
You must be signed in to change notification settings - Fork 0
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
[스택, 큐, 덱] 9월 15일 #3
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uC2A4\uD0DD,-\uD050,-\uB371"
Conversation
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
수고하셨습니다! 1935번에 중복코드가 약간 있긴 하지만 다른 문제들은 아주 효율적으로 잘 푸셨어요~~
지금 작성하신 코드들에 함수화를 할 수 있을 부분들이 좀 보여요! 어떠한 연산결과를 리턴한다면 다 함수로 뺀다고 생각하고 리팩토링해볼까요?
시간이 없으시면 1935번에서 중복코드만 수정하셔도 돼요!
수정 후 리뷰어로 저 호출해주세요~~
|
||
int main(){ |
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.
와 이걸 직접구현하셨네요! 정말 잘하셨어요!!
근데 사실 삭제&삽입 연산은 front와 back에서 아주 약간 다르게 작동해요!
아무튼 정말 멋져요...!
map<char, double> value; | ||
for (int i = 0; i < n; i++) { | ||
cin >> t; | ||
value['A' + i] = t; | ||
} |
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.
map도 좋지만, 다른 방법도 있어요! 코드를 잘 살펴보시면 답이 나올 것 같아요~
else if(c == '*'){ | ||
a = st.top(); | ||
st.pop(); | ||
b = st.top(); | ||
st.pop(); | ||
st.push(a*b); | ||
} | ||
else if(c == '+'){ | ||
a = st.top(); | ||
st.pop(); | ||
b = st.top(); | ||
st.pop(); | ||
st.push(a+b); | ||
} | ||
else if(c == '/'){ | ||
a = st.top(); | ||
st.pop(); | ||
b = st.top(); | ||
st.pop(); | ||
st.push(b/a); | ||
} | ||
else if(c == '-'){ | ||
a = st.top(); | ||
st.pop(); | ||
b = st.top(); | ||
st.pop(); | ||
st.push(b-a); | ||
} |
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.
여기 중복이 많네요! 사칙연산 함수를 만드는건 어떨까요?
//벡터에 맵 입력 | ||
vector<pair<string, int>> answer(word.begin(), word.end()); |
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.
👍
//스택에 인형 종류 입력 | ||
for(int i=n-1; i>=0; i--){ | ||
for(int j=0; j<n; j++){ | ||
if(board[i][j] != 0) | ||
doll[j].push(board[i][j]); | ||
} | ||
} |
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(doll[move-1].empty()) | ||
continue; |
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.
잘 끊으셨습니다!
No description provided.