목록알고리즘/[2020] 알고리즘 과제 (5)
알맹이방
#include "maxSum.h" // DO NOT modify constuctor and distructor... maxSum::maxSum(int n, int* m){ int i=0; if(!m)return; num = n; money = new int[n]; for(i=0;i
#include #include #include "concat.h" using namespace std; concat::concat(void){ this->num = 0; this->pa = 0; return; } concat::concat(int* priority, char **words, int n){ int i=0; this->num = n; this->pa = new pri* [n]; for(i=0;ipa[i] = new pri(priority[i], words[i]); return; } concat::~concat(void){ if(this->pa){ int i=0, n = this->num; for(i=0;ipa[i])delete this->pa[i]; delete[] this->pa; } r..
#include #include "closest.h" #if 0 DO NOT MODIFY closest(void), ~closest(void), and setPoints(point* p, int n)! #endif closest::closest(void){ this->pnt = NULL; this->num = 0; return; } closest::~closest(void){ if(this->pnt)delete this->pnt; return; } void closest::setPoints(point* p, int n){ int i=0; if(this->pnt)delete this->pnt; this->pnt = new point[n]; this->num = n; for(i=0;ipnt[i] = p[i]..
#include #include "inv.h" #define MODE 0 using namespace std; inv::inv(){ this->array = NULL; this->size = 0; } inv::~inv(){ if(this->array)delete this->array; return; } void inv::reset(int *a, int s){ int i=0; if(this->array)delete this->array; this->array = new int[s]; this->size = s; for(i=0;iarray+i) = *(a+i); return; } void inv::printArray(void){ int i = 0; for(i=0;i