Skip to content

[정렬, 맵, 셋] 8월 20일#1

Open
chocofall wants to merge 4 commits intomainfrom
week1
Open

[정렬, 맵, 셋] 8월 20일#1
chocofall wants to merge 4 commits intomainfrom
week1

Conversation

@chocofall
Copy link
Copy Markdown
Collaborator

@chocofall chocofall commented Aug 20, 2024

인적사항

학번: 2317014
이름: 박나림

과제 제출

기존 제출: 19636, 1431, 14425
추가 제출:

Copy link
Copy Markdown

@chae-jpg chae-jpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[정렬, 맵, 셋 구현 코드리뷰 완료]
14425(P2)

나림님 안녕하세요! 코드 리뷰 완료되었습니다👍

다음부터는 간단한 주석이 있으면 더 좋을 것 같아요!
몇 가지 사소한 코멘트 남겼습니다!

궁금하신 점이 있다면 언제나 리뷰어를 호출해주세요😊

Comment thread 14425_SV.cpp
Comment on lines +7 to +8
int n, m, cnt = 0;
set <string> s;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2
알튜비튜에서는 작업 시 발생할 수 있는 혼란을 막기 위해 전역변수 사용을 최대한 지양하고 있습니다!
이 문제의 경우에는 지역변수로 둔 뒤, 매개변수로 넘겨서도 충분히 문제를 해결할 수 있을 것 같아요 👍

Comment thread 14425_SV.cpp
using namespace std;

int n, m, cnt = 0;
set <string> s;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

탐색에 용이한 셋 자료구조를 사용해서 문제를 효율적으로 해결해주셨네요!

Comment thread 14425_SV.cpp
Comment on lines +21 to +25
for (int i = 0; i <m; i++){
string tmp;
cin >> tmp;
if (s.find(tmp) != s.end()) cnt++;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3
알튜비튜에서는 입출력을 제외한 코드는 다른 함수로 분리하는 것을 권장하고 있습니다.
입출력은 메인에 두고, 탐색하는 부분은 findString과 같은 이름의 함수로 분리하면 더 좋을 것 같아요!👍

Copy link
Copy Markdown

@flowing1ife flowing1ife left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[정렬, 맵, 셋 구현 코드리뷰 완료]
1431(P1)

코드 리뷰 완료하였습니다 !
전체적으로 주석을 추가해서 코드의 가독성을 높이면 더욱 좋을 것 같습니다 ㅎㅎ
몇 가지 사소한 코멘트 남겼으니 확인해주세요 😊

Comment thread 1431_SERIAL.cpp
using namespace std;

int n;
string a[1000];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1
string이 아닌 vector를 사용해서 main 함수에 n개만큼 초기화해준다면 메모리 측면에서도 효율적이고 훨씬 더 코드가 간결해져요 !

Comment thread 1431_SERIAL.cpp
return sum;
}

bool compare (string a, string b){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2

cmp 함수의 경우, 두 인자를 비교하기 때문에 중간에 값이 바뀌지 않도록 상수로 선언하는 것을 권장 드리며 단순히 값을 복사하는 것이 아닌 포인터로 값을 정확히 가져오는 것을 추천드립니다.
bool compare(const string& a, const string& b)

Comment thread 1431_SERIAL.cpp
Comment on lines +22 to +41
if(a.length()<b.length()){
return 1;
}
else if (a.length()>b.length()){
return 0;
}
else {
int sum_a = integer_sum(a);
int sum_b = integer_sum(b);

if (sum_a < sum_b){
return 1;
}
else if (sum_a > sum_b) {
return 0;
}
else {
return a < b;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2
둘의 길이가 같지 않음을 기준으로 한다면 if문이 깊어지지 않고 코드가 간결해질 수 있어요 !

Comment thread 1431_SERIAL.cpp
int length = a.length();
int sum =0;
for(int i = 0; i <length; i++){
if (a[i]-'0' <= 9 && a[i]-'0'>=0){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2
isdigit 함수를 사용하면 숫자의 여부를 바로 확인할 수 있어요 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants