본문 바로가기

둥지47

[프로그래머스] 컨트롤 제트 문제링크 #include #include #include using namespace std; int solution(string s) { int answer = 0; stringstream ss(""); ss.str(s); stack numbers = {}; while (false == ss.eof()) { string str = {}; ss >> str; if ("Z" == str) { answer -= numbers.top(); continue; } int num = stoi(str); numbers.push(num); answer += num; } return answer; } 2023. 2. 26.
퀵 정렬 #include #include template class DataManager { public: DataManager() {}; DataManager(size_t _Size) { Datas.resize(_Size); }; ~DataManager() {}; void Swap(T& _Left, T& _Right) { T Temp(_Left); _Left = _Right; _Right = Temp; } size_t Partition(size_t _Left, size_t _Right) { T Pivot = Datas[_Left]; size_t Low = _Left; size_t High = _Right; while (Low < High) { while (Pivot < Datas[High]) { --High; .. 2023. 2. 26.
버블 정렬 #include #include template class DataManager { public: DataManager() {}; DataManager(size_t _Size) { Datas.resize(_Size); }; ~DataManager() {}; void Swap(T& _Left, T& _Right) { T Temp(_Left); _Left = _Right; _Right = Temp; } bool Compare(const T& _Left, const T& _Right) { return _Left < _Right; } void BubbleSort() { size_t Size = Datas.size(); for (size_t i = 0; i < Size - 1; ++i) { for (size_t .. 2023. 2. 25.
Array, Vector 구현 #include #include #include using namespace std; template class Array { T* Array_; size_t Size_; public: Array() : Array_(nullptr) , Size_(S) { Array_ = new T[Size_]; } ~Array() { delete[] Array_; Array_ = nullptr; } size_t Capacity() { return Size_; } void Resize(size_t _Size) { T* Temp = Array_; Array_ = new T[_Size]; for (size_t i = 0; i < _Size; i++) { Array_[i] = Temp[i]; } if (nullptr != Te.. 2023. 2. 20.
[백준 1992] 쿼드 트리 문제링크 #include #include char arr[100][100] = {}; void f(int a, int b, int n) { int flag = 0; int j = 0; for (int i = 0; i arr[i]; } f(0, 0, n); return 0; } 2023. 2. 20.
리스트 구현 #include template class LinkedList { class Node { friend LinkedList; public: Node() {}; Node(T& _data) : data(_data), next(nullptr), prev(nullptr) { } T data; Node* next; Node* prev; }; public: LinkedList() : head(new Node()) , tail(new Node()) { head->next = tail; tail->prev = head; } ~LinkedList() { Node* node = head; while (nullptr != node) { Node* next = node->next; delete node; node = nullp.. 2023. 2. 17.