Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions 01-정렬/필수/11478.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
#include <string>
#include <set>

using namespace std;
int main() {
string str;
cin >> str;
set<string> S;
int N = str.size();
for (int i = 0; i < N; i++) {
for (int len = 1; len <= N - i; len++) {
S.insert(str.substr(i, len));
}
}
cout << S.size();
return 0;
}
18 changes: 1 addition & 17 deletions 01-정렬/필수/1431.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,7 @@ int compare(string a, string b) {
int b_size = b.size();
int a_sum = 0;
int b_sum = 0;
if (a_size != b_size) {
return a_size < b_size;
}
else {
for (int i = 0; i < a_size; i++) {
if (a[i] >= '0' && a[i] <= '9') {
a_sum += int(a[i]) - 48;
}
if (b[i] >= '0' && b[i] <= '9') {
b_sum += int(b[i]) - 48;
}
}
if (a_sum != b_sum) {
return a_sum < b_sum;
}
}
return a < b;

}
int main() {
int N;
Expand Down
41 changes: 41 additions & 0 deletions 01-정렬/필수/19636.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
#include <cmath>
using namespace std;

int main() {
int W0, I0, T, D, I, A;

cin >> W0 >> I0 >> T;
cin >> D >> I >> A;

int W1 = W0; //���ʴ�緮 ��ȭ �ݿ� ����
int W2 = W0; //���� ��緮 ��ȭ �ݿ� ��

int I1 = I0; //��ȭ�� ���ʴ�緮 ����

for (int i = 0; i < D; i++) {
W1 += I - (I0 + A);
W2 += I - (I1 + A);
if (abs(I - (I1 + A)) > T) {
I1 += floor((I - (I1 + A)) / 2.0);
}
}
if (W1 <= 0 || I0 <= 0) {
cout << "Danger Diet\n";
}
else {
cout << W1 << ' ' << I0 << '\n';
}
if (W2 <= 0 || I1 <= 0) {
cout << "Danger Diet";
}
else {
cout << W2 << ' ' << I1 << ' ';
if (I0 - I1 > 0) {
cout << "YOYO";
}
else {
cout << "NO";
}
}
}
28 changes: 28 additions & 0 deletions 02-스택,큐,덱/필수/10757.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>

Choose a reason for hiding this comment

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

전반적으로 잘 푸셨습니다☺️
다만, 현재 github 상에서 주석이 깨져있습니다. 인코딩 문제로 보이는데, IDE에서 인코딩 형식을 바꾸어 해결할 수 있으니 링크 참고해서 설정해보세요! 설정 상 어려운 점이 있으시면 언제든지 편하게 질문해주세요!!

#include <string>
#include <algorithm>
using namespace std;

int main() {
string A, B;
cin >> A >> B;
Comment on lines +7 to +8

Choose a reason for hiding this comment

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

p3. 저희 코드 규칙에 변수는 소문자로 시작하는 camelCase, 상수는 대문자 + snake 표기법을 쓰기로 되어 있어요! 컨벤션에 맞추어 변수는 소문자로 작성해주시면 더 좋을거 같아요!

Choose a reason for hiding this comment

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

죄송합니다. 변수는 소문자 snake_case입니다!


//�� ������ ���̸� ���� ª�� �� �տ� 0�� �߰���
while (A.length() < B.length()) A = '0' + A;
while (B.length() < A.length()) B = '0' + B;
Comment on lines +11 to +12

Choose a reason for hiding this comment

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

크기를 맞추어서 자릿수 문제를 해결하신 부분 좋아요👍


string result = "";
int round = 0; //�ڸ��ø�����

//�ڿ��� ���� ���ʴ�� ����
for (int i = A.length() - 1; i >= 0; i--) {
int sum = (A[i] - '0') + (B[i] - '0') + round;
round = sum / 10; //10�� ������ 1�� �ø�
result += (sum % 10) + '0'; //�ڸ��� �ϳ� �߰���
}

if (round) result += '1'; //���������� �ø��� ���������� �ڸ��� �ø�

Choose a reason for hiding this comment

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

마지막 올림수까지 반영 잘 해주셨네요!

reverse(result.begin(), result.end()); //�ڿ��� ���� ��������� reverse�� ����� ���

cout << result;
}
31 changes: 31 additions & 0 deletions 02-스택,큐,덱/필수/2164.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
#include <queue>
using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);

//N�� �Է¹ޱ�
int N;
cin >> N;
Comment on lines +10 to +11

Choose a reason for hiding this comment

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

컨벤션에 따라 상수명만 대문자로 작성해주시면 좋을 것 같아요! 변수와 상수를 이름만 보고도 구분이 가능하도록 하기 위함이니 참고부탁드립니다!


//1���� N���� ��� queue����
queue<int> Q;

Choose a reason for hiding this comment

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

큐 자료구조를 적절히 잘 사용해주셨네요!

for (int i = 1; i <= N; i++) {
Q.push(i);
}

//���� ���Ǵ�� ������ �ϳ��� ���� ������ ����

Choose a reason for hiding this comment

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

주석이 깨져있는데 인코딩 한 번 확인해보시면 좋을 것 같아요!

while (Q.size() != 1) {

Choose a reason for hiding this comment

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

틀린 표현은 아니지만 로직 상 Q.size() > 1 이 더 적합한 표현일 것 같습니다!

//���� �տ� �ִ� �� ����
Q.pop();
//�״������� �տ� �ִ� ���� queue�� ����
Q.push(Q.front());
//���� �տ� �ִ� �� ����. �̷��� ��������� �տ� �ִ� ���� �ڷ� �������� �ȴ�.
Q.pop();
Comment on lines +22 to +26

Choose a reason for hiding this comment

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

간결하고 효율적으로 코드 잘 작성해주셨네요!

}

cout << Q.front();
return 0;
}
57 changes: 57 additions & 0 deletions 02-스택,큐,덱/필수/4949.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
while (true) {
//�ٺ��� ���� �Է¹ޱ�
string input;
getline(cin, input);
Comment on lines +9 to +12

Choose a reason for hiding this comment

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

while(getline(cin, input)) 으로도 줄일 수 있을 것 같아요!


//.�� �ԷµǸ� while�� ������
if (input == ".") {
break;
}
//������ ��ȣ�� ���� stack�� yes/no�� ǥ���� result ����
stack<char> S;
bool result = true;
for (int i = 0; i < input.length(); i++) {

Choose a reason for hiding this comment

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

괄호가 균형을 이루는지 확인하는 부분은 따로 함수화하면 좋을 것 같아요!

//����ȿ� ���� ��ȣ�� ������ stack�� ���(push)
if (input[i] == '[' || input[i] == '(') {
S.push(input[i]);
}
//����ȿ� �ݴ� ��ȣ�� ������
if (input[i] == ']') {
//stack�� ������� �ʰ�(empty()�� 0) stack�� ���� ���� ���� ¦�� ���� ��ȣ�̸� stack�� ���� ���� ���� ����(pop)
if (S.empty() == 0 && S.top() == '[') {
S.pop();
}
//�ƴ϶�� result�� false�� �ٲٰ� while�� ����
else {
result = false;
break;
}
}
if (input[i] == ')') {
if (S.empty() == 0 && S.top() == '(') {
S.pop();
}
else {
result = false;
break;
}
}
}
//stack�� ����ְ� result�� true��� yes���
if (S.empty() == 1 && result == true) {
cout << "yes" << endl;
}
//�ƴ϶�� no���
else {
cout << "no" << endl;
}
}
}