diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..03aeff6 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": "구성 없음" +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..dcfdc46 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,10 @@ +{ + "ExpandedNodes": [ + "", + "\\Minju", + "\\Minju\\BOJ", + "\\stack" + ], + "SelectedNode": "\\Minju\\BOJ\\9375", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/data-structure/v16/.suo b/.vs/data-structure/v16/.suo new file mode 100644 index 0000000..8036642 Binary files /dev/null and b/.vs/data-structure/v16/.suo differ diff --git a/.vs/data-structure/v16/Browse.VC.db b/.vs/data-structure/v16/Browse.VC.db new file mode 100644 index 0000000..64de9f1 Binary files /dev/null and b/.vs/data-structure/v16/Browse.VC.db differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..e39acb4 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/Minju/linked_list/linkedlist.c b/Minju/linked_list/linkedlist.c new file mode 100644 index 0000000..1a98fc6 --- /dev/null +++ b/Minju/linked_list/linkedlist.c @@ -0,0 +1,151 @@ +#include +#include + +#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; + } +} \ No newline at end of file diff --git "a/Minju/BOJ/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214.cpp" "b/Minju/map_heap/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214.cpp" similarity index 100% rename from "Minju/BOJ/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214.cpp" rename to "Minju/map_heap/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214/7785-\355\232\214\354\202\254\354\227\220 \354\236\210\353\212\224 \354\202\254\353\236\214.cpp" diff --git "a/Minju/BOJ/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210.cpp" "b/Minju/map_heap/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210.cpp" similarity index 100% rename from "Minju/BOJ/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210.cpp" rename to "Minju/map_heap/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210/9375-\355\214\250\354\205\230\354\231\225 \354\213\240\355\225\264\353\271\210.cpp" diff --git "a/Minju/queue/1966-\355\224\204\353\246\260\355\204\260 \355\201\220/1966-\355\224\204\353\246\260\355\204\260 \355\201\220.cpp" "b/Minju/queue/1966-\355\224\204\353\246\260\355\204\260 \355\201\220/1966-\355\224\204\353\246\260\355\204\260 \355\201\220.cpp" new file mode 100644 index 0000000..4d648cd --- /dev/null +++ "b/Minju/queue/1966-\355\224\204\353\246\260\355\204\260 \355\201\220/1966-\355\224\204\353\246\260\355\204\260 \355\201\220.cpp" @@ -0,0 +1,63 @@ +#include +#include +#include +using namespace std; + +int numberth(int n, int m) { + queue> papers; + list priority; + int input, count=0; + pair target, curr; + for (int j = 0; j < n; j++) { + cin >> input; + priority.push_back(input); + papers.push(pair(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 +*/ \ No newline at end of file diff --git "a/Minju/queue/9012-\352\264\204\355\230\270/9012-\352\264\204\355\230\270.cpp" "b/Minju/queue/9012-\352\264\204\355\230\270/9012-\352\264\204\355\230\270.cpp" new file mode 100644 index 0000000..ba48130 --- /dev/null +++ "b/Minju/queue/9012-\352\264\204\355\230\270/9012-\352\264\204\355\230\270.cpp" @@ -0,0 +1,41 @@ +#include +#include +#include +using namespace std; + +void isVps(char pString[51], int size) { + stackparenthesis; + 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; +} \ No newline at end of file diff --git "a/Minju/recursive_function/10872-\355\214\251\355\206\240\353\246\254\354\226\274/10872-\355\214\251\355\206\240\353\246\254\354\226\274.cpp" "b/Minju/recursive_function/10872-\355\214\251\355\206\240\353\246\254\354\226\274/10872-\355\214\251\355\206\240\353\246\254\354\226\274.cpp" new file mode 100644 index 0000000..a80fb95 --- /dev/null +++ "b/Minju/recursive_function/10872-\355\214\251\355\206\240\353\246\254\354\226\274/10872-\355\214\251\355\206\240\353\246\254\354\226\274.cpp" @@ -0,0 +1,15 @@ +#include +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)); +} \ No newline at end of file diff --git "a/Minju/recursive_function/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234.cpp" "b/Minju/recursive_function/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234.cpp" new file mode 100644 index 0000000..bc66a27 --- /dev/null +++ "b/Minju/recursive_function/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234/11729-\355\225\230\353\205\270\354\235\264 \355\203\221 \354\235\264\353\217\231 \354\210\234\354\204\234.cpp" @@ -0,0 +1,17 @@ +#include +#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); +}