-
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
[정렬_맵_셋] 8월 23일 #1
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "01_\uC815\uB82C_\uB9F5_\uC14B"
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.
[정렬, 맵, 셋 구현 추가제출 확인 완료]
안녕하세요 예원님~ 필수 구현 뮨제(19636) 추가제출 확인 완료되셨습니다! 수고 많으셨습니다~
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: 안녕하세요 예원님! 필수 문제 1431번, 14425번 코드리뷰 완료했습니다.😊 두 문제 모두 잘 풀어 주셔서 특별히 코멘트 남겨드릴 만한 부분은 많이 없었습니다! 간단한 제안사항을 코멘트로 남겨 드렸으니 확인해보시면 좋을 것 같습니다. 수고하셨어요:)👍👍
int sum(string a) { | ||
int result = 0; | ||
|
||
for (int i = 0; i < a.length(); i++) { | ||
int anum = a[i] - '0';//string to int | ||
if (anum >= 0 && anum <= 9) { //�����̸� ���� | ||
result = result + anum; | ||
} | ||
} | ||
return result; | ||
} |
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.
자릿수 합 구하는 함수 따로 구현하신 것 너무 좋아요!😍 문자의 숫자 여부를 판별할 때 string헤더의 isdigit 함수를 사용하는 방법도 알아두시면 편리할 것 같습니다.👍👍
int asum = sum(a); | ||
int bsum = sum(b); | ||
if (asum != bsum) { //(���� ������) �ڸ��� �� ���� �� ���� | ||
return asum < bsum; | ||
} |
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와 return에서 asum과 bsum 대신 sum함수를 바로 호출한다면 더 간결한 코드가 될 수 있을 것 같습니다!😀
auto iter = s.find(str); //key�� ���� ���� Ȯ�� | ||
if (iter != s.end()) { //�����ϸ� cnt 1 ����, (�������� ������ s.end()�� ��ȯ��) | ||
cnt++; | ||
} |
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<string, int> s; | ||
|
||
//�Է� | ||
cin >> n >> m; | ||
|
||
for (int i = 0; i < n; i++) { //���� S�� map���� ���� | ||
cin >> str; | ||
s[str] = value; | ||
value++; | ||
} |
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을 사용해서 문제를 잘 풀어 주셨습니다!😍 샘플 코드 참고하셔서 set으로 푸는 방법도 한 번 알아보시면 좋을 것 같아요~👍
인적사항
학번: 2171060
이름: 김예원
과제제출
기존 제출: 1431, 14425
추가 제출: 19636