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
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "구성 없음"
}
10 changes: 10 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ExpandedNodes": [
"",
"\\Minju",
"\\Minju\\BOJ",
"\\stack"
],
"SelectedNode": "\\Minju\\BOJ\\9375",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/data-structure/v16/.suo
Binary file not shown.
Binary file added .vs/data-structure/v16/Browse.VC.db
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
151 changes: 151 additions & 0 deletions Minju/linked_list/linkedlist.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#include <stdio.h>
#include <stdlib.h>

#include "linked_list.h"

linked_list_t linked_list;

void linked_list_add_first(int data) { // add 'data' at the beginning of list
node* tmp;
tmp = (node*)malloc(sizeof(node));
tmp->next = linked_list.head;
tmp->data = data;
linked_list.size++;
linked_list.head = tmp;
}

void linked_list_add_last(int data) { // add 'data' at the end of list
node* ptr = linked_list.head;;
node* tmp = (node*)malloc(sizeof(node));
tmp->data = data;
tmp->next = NULL;

for(;;){
if (ptr->next == NULL)
break;
ptr = ptr->next;
}
ptr->next = tmp;
linked_list.size++;

}

int linked_list_get_first() { // return 'data' of first item
node* ptr = linked_list.head;
if (ptr == NULL) {
printf("empty");
return -1;
}
return ptr->data;
}

int linked_list_get_last() { // return 'data' of last item
node* ptr = linked_list.head;
if (ptr == NULL) {
printf("empty");
return -1;
}
while (ptr->next != NULL) {
ptr = ptr->next;
}
return ptr->data;
}

void linked_list_delete_first() { // delete first item
node* tmp = linked_list.head;
linked_list.head = linked_list.head->next;
free(tmp);
linked_list.size--;
}

void linked_list_delete_last() { // delete last item
node* prev = linked_list.head;
node* curr = prev->next;
while (1) {
if (curr == NULL) {
break;
}
if (curr->next == NULL) {
prev->next = NULL;
free(curr);
break;
}
prev = prev->next;
curr = curr->next;
}
linked_list.size--;
}

int linked_list_size() { // return the number of items in list
return linked_list.size;
}

int linked_list_exist(int data) { // find 'data'. return true(1)/false(0)
node* ptr = linked_list.head;
while (ptr != NULL) {
if (ptr->data == data)
return 1;
ptr = ptr->next;
}
return 0;
}

void linked_list_delete(int data) { // find 'data' in the list, and delete
node* prev = linked_list.head;
node* curr = prev->next;
while (prev != NULL) {
if (prev->data == data) {
linked_list.head = curr;
free(prev);
break;
}
if (curr->data == data) {
prev->next = curr->next;
free(curr);
break;
}
prev = prev->next;
curr = curr->next;
}
linked_list.size--;
}

void linked_list_delete_index(int i) { // delete 'i'-th item in the list
node* ptr = linked_list.head;
node* tmp = linked_list.head;
if (linked_list.size == 0)
return;
for (int count = 0; count < i - 1; count++) {
tmp = ptr;
ptr = ptr->next;
}
tmp->next = ptr->next;
if (i == 1)
linked_list.head = tmp->next;
free(ptr);
linked_list.size--;
}

void linked_list_delete_all() { // delete dall data
node* tmp = linked_list.head;
node* ptr = linked_list.head->next;
while (1) {
free(tmp);
if (ptr == NULL) {
linked_list.head = NULL;
linked_list.size = 0;
break;
}
tmp = ptr;
ptr = ptr->next;
}
linked_list.size = 0;
}

void linked_list_print() {
node* tmp = linked_list.head;
while (tmp != NULL) {
printf("%d\n", tmp->data);
tmp = tmp->next;
}
}
63 changes: 63 additions & 0 deletions Minju/queue/1966-프린터 큐/1966-프린터 큐.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include<iostream>
#include<queue>
#include<list>
using namespace std;

int numberth(int n, int m) {
queue<pair<int, int>> papers;
list<int> priority;
int input, count=0;
pair<int, int> target, curr;
for (int j = 0; j < n; j++) {
cin >> input;
priority.push_back(input);
papers.push(pair<int, int>(input, j));
if (j == m) {
target.first = input;
target.second = j;
}
}
priority.sort();
priority.reverse();
while (1) {
curr = papers.front();
if (curr.first < priority.front()) {
papers.pop();
papers.push(curr);
}
else {
++count;
if (curr.second == target.second)
break;
papers.pop();
priority.pop_front();
}
}
return count;
}

int main() {
cin.tie(NULL);
cin.sync_with_stdio(false);
int testCase, n, m;
cin >> testCase;
for (int i = 0; i < testCase; i++) {
cin >> n >> m;
cout << numberth(n, m) << '\n';
}
}

/*
Q�� ������ ��´�
�߿䵵�� ��´�
������ �߿䵵�� ���� ����
test case
������ ��, �� ������ �μ�Ǿ����� �ñ��� ������ ���� ť������ ��ġ
ť�� 0�� ���� ����
�켱���� ���� ������ ť����
0��° ��ġ�� �ִ� ������ �� ��°�� �μ�dz�!
(���� �� - �켱����)
1.�켱���� �˻�(���� ���� �ִ��� Ȯ��)
a b c d e f g
c d e f g a b
*/
41 changes: 41 additions & 0 deletions Minju/queue/9012-괄호/9012-괄호.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include<iostream>
#include<stack>
#include<string>
using namespace std;

void isVps(char pString[51], int size) {
stack<char>parenthesis;
for (int j = 0; j < size; j++) {
if (pString[j] == '(')
parenthesis.push(pString[j]);
else {
if (parenthesis.empty()) {
cout << "NO" << '\n';
return;
}
parenthesis.pop();
}

}
if (parenthesis.empty())
cout << "YES" << '\n'; //�빮�� �ҹ���...���1.1.....
else
cout << "NO" << '\n';
return;
}

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

int num, size;
cin >> num;

for (int i = 0; i < num; i++) {
char pString[51];
cin >> pString;
size = strlen(pString);
isVps(pString, size);
}
return 0;
}
15 changes: 15 additions & 0 deletions Minju/recursive_function/10872-팩토리얼/10872-팩토리얼.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<iostream>
using namespace std;
int factorial(int num) {
int result=1;
if (num > 1) {
result = num * factorial(num - 1);
}
return result;
}

int main() {
int num;
scanf("%d", &num);
printf("%d", factorial(num));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
#pragma warning (disable: 4996)
void hanoiTop(int n, int from, int to, int other) {
if (n == 0) { return; }
hanoiTop(n - 1, from, other, to);
printf("%d %d\n", from, to);
hanoiTop(n - 1, other, to, from);
}

int main() {

int n, count = 1;
scanf("%d", &n);
count = (1 << n) - 1;
printf("%d\n", count);
hanoiTop(n, 1, 3, 2);
}