CS

    [C] 인접리스트로 그래프 구현

    // 그래프를 인접리스트로 표현하기 #include "stdio.h" #include "stdlib.h " #define MAX_VERTEX 30 // 인접리스트의 노드 구조 typedef struct graphNode { int vertex; // 정점을 나타내는 데이터 필드 graphNode *link; // 다음 인접 정점을 연결하는 링크필드 }graphNode; // 그래프를 인접리스트로 표현하기 위한 구조체 typedef struct graphType { int n; //정점 개수 graphNode *adjList_Arr[MAX_VERTEX]; }graphType; // 공백그래프를 생성하는 연산 void CreateGraph(graphType *ptr) { int v; ptr->n = 0; f..

    Stack (스택) 구현

    #include using namespace std; class MyIntStack { int* p; int size; int tos;public: MyIntStack() {}; MyIntStack(int size); MyIntStack(MyIntStack& s); ~MyIntStack(); bool Push(int n); bool Pop(int& n);}; int main() { MyIntStack a(10); a.Push(10); a.Push(20); MyIntStack b = a; b.Push(30); int n; a.Pop(n); cout size = size;} MyIntStack::MyIntStack(..

    객체지향 - SOLID 개발 5대 원리

    S - SRP(Single responsibility principle) 단일 책임 원칙 - 모든 클래스는 단 하나의 책임을 가져야한다. O - OCP(Open Closed Principle) 개방 - 폐쇄 원칙 - 확장에 대해서는 개방 되어 있어야 하지만, 수정에 대해서는 폐쇄 되어야 한다. L - LSP(liskov substitusion Principle) 리스코프 치환 법칙 - 문제 없이 업캐스팅(Up-Casting, 부모의 객체로 자식의 객체를 가르킬 수 있는 것)이 되야한다. I - ISP(Interface Segregation Principle) 인터페이스 분리 원칙 - 자신이 이용하지 않는 클래스를 의존하지 않아도 된다 혹은 아예 의존시키지 말아야한다. D - DIP(Dependency I..