![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fba3ORR%2FbtqEgQ6CAlG%2FdcjdRjr7Lxsf4ahj5HnS3k%2Fimg.png)
[C++] 셔플(Shuffle) 알고리즘
2020. 5. 16. 21:19
C++/공부
코드 #include #include using namespace std; int main() { srand(time(NULL)); int number[10]; int dest, sour, temp; for (int i = 0; i < 10; i++) number[i] = i + 1; // 셔플 알고리즘 // i의 조건은 섞고 싶은 만큼 지정하기 for (int i = 0; i < 77; i++) { dest = rand() % 10; sour = rand() % 10; temp = number[dest]; number[dest] = number[sour]; number[sour] = temp; } for (int i = 0; i < 10; i++) cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fy4jrP%2FbtqEvhoGpS3%2F89n3lVqZjuRNKs4hXhjnw1%2Fimg.png)
[알고리즘 문제] 02. 자연수의 합
2020. 5. 15. 21:48
문제 풀이/알고리즘 문제풀이
코드 #include using namespace std; int main() { int a, b; int sum = 0; cin >> a >> b; for (int i = a; i
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FwnvLi%2FbtqEuyY0iZc%2FtwKskqrTR705xUHv9Uwqn1%2Fimg.png)
[알고리즘 문제] 01. 1부터 N까지 M의 배수합
2020. 5. 14. 18:56
문제 풀이/알고리즘 문제풀이
코드 #include using namespace std; int main() { int n, m; int sum = 0; cin >> n >> m; for (int i = 1; i
5월 중순의 근황과 학원 등록!
2020. 5. 13. 16:15
중얼중얼
요즘 너무 나태해지기도 했고 이래저래 포폴 때문에 고민이 많아져서 국비 학원 찾아보다가 상담도 다녀왔는데 꽤 괜찮아 보여서 흔쾌히 등록했다! 거리가 멀어서 출퇴근 시간 너무 걱정이긴 한데... 그래도 환승 안 하고 지하철 쭉 타고 다니면 되니까 며칠 해 보면 익숙해지지 않을까 싶다 😥 지금은 백준 기초 문제 쪼끔 풀고 있긴 한데 C++에 조금씩 익숙해지면서 하루에 몇 개씩 꾸준하게 해 볼까 싶다 하도 코딩을 안 했더니 머리가 굳어가는 것 같다 오늘 상담 다녀오고 나의 부족함을 뼈저리게 느꼈어 ㅋㅋㅋㅋ ㅠㅠ 아는 건데도 입 밖으로 말하려니까 너무 힘들다 면접 때는 어떻게 하려고 이러나ㅏㅏㅏㅏ 그나저나 지금 청년구직활동지원금 2개월째 받고 있는데 국민내일배움카드랑 중첩해서 혜택받을 수 있는 거 너무 좋은 것..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FTdzK2%2FbtqEUpng0gh%2FpQ5yffgjzf5Yjk2C8pjONK%2Fimg.png)
[C++] 따라하며 배우는 C++ - (14) 예외 처리
2020. 5. 5. 19:23
C++/따라하며 배우는 C++
예외처리의 기본 #include #include #include using namespace std; int findFirstChar(const char * string, char ch) { for (std::size_t index = 0; index < strlen(string); ++index) if (string[index] == ch) return index; return -1;// no match } // 리턴값을 bool로 처리할 수도 있음 double divide(int x, int y, bool &success) { if (y == 0) { success = false; return 0.0; } success = false; return static_cast(x) / y; } int mai..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcWB16t%2FbtqEIUsZqw7%2FaKDFgtWGL9p1xQ2dksq6nK%2Fimg.png)
[C++] 따라하며 배우는 C++ - (13) 템플릿
2020. 5. 4. 13:59
C++/따라하며 배우는 C++
함수 템플릿 프로그래머의 단순 반복 작업을 줄여 주기 위한 장치가 있다. 템플릿은 여러 가지 자료형에 대해서 비슷한 코드를 반복하는 것을 방지해 준다. Cents.h #pragma once #include class Cents { private: int m_cents; public: Cents(int cents) : m_cents(cents) { } friend bool operator > (const Cents &c1, const Cents &c2) { return (c1.m_cents > c2.m_cents); } friend std::ostream& operator
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FU09aG%2FbtqEvYYBR48%2Fz5nrwD4mto3s8ccbJADCBK%2Fimg.png)
[C++] 따라하며 배우는 C++ - (12) 가상 함수들
2020. 5. 3. 20:28
C++/따라하며 배우는 C++
다형성의 기본 개념 자식 클래스 객체에 부모 클래스 포인터를 사용한다면? #include #include using namespace std; class Animal { protected: string m_name; public: Animal(std::string name) : m_name(name) {} public: string getName() { return m_name; } //void speak() const virtual void speak() const { cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FczZr6G%2FbtqEqr7DChk%2Fi4eohlIpOItXnnJKwY7Okk%2Fimg.png)
[C++] 따라하며 배우는 C++ - (11) 상속
2020. 5. 2. 19:14
C++/따라하며 배우는 C++
상속의 기본 (1) Inheritance(is-a relationship) #include using namespace std; class Mother// generalized class { private:// 자식한테도 허용X //public:// 다 열어 버림 //protected:// private 상태를 유지하면서 자식에게는 허용 int m_i; public: Mother(const int & i_in) : m_i(i_in) { std::cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fdn5qwO%2FbtqElXySddw%2FcxYieQaPljL9kXBKy0mukK%2Fimg.png)
[C++] 따라하며 배우는 C++ - (10) 객체들 사이의 관계에 대해
2020. 4. 30. 01:36
C++/따라하며 배우는 C++
객체들의 관계 1. 프로그램이 수행해야 하는 기능 정하기 2. 어떤 객체들이 어떻게 나눠서 도움을 주고받을지 설계 3. 설계에 따라서 여러 클래스를 구현 구성(요소) 관계 Composition Part-of 두뇌는 육체의 일부이다. 육체 없이는 존재할 수 없으며, 두뇌가 육체 전체에 대해 알고 있지는 않다. 전체/부품 - 육체/두뇌 다른 클래스에도 속할 수 없음 - 두뇌는 다른 클래스에 속할 수 없음 멤버의 존재를 클래스가 관리함 - 두뇌를 육체가 관리함 단방향 Position2D.h #pragma once #include class Position2D { private: int m_x; int m_y; public: Position2D(const int & x_in, const int & y_in) :..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fc6g87X%2FbtqEeZIeBCb%2FZHZNLHo295aTXfqkiyJxXk%2Fimg.png)
[백준/C++] 1110번: 더하기 사이클
2020. 4. 29. 15:20
문제 풀이/백준
문제 0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음, 주어진 수의 가장 오른쪽 자리 수와 앞에서 구한 합의 가장 오른쪽 자리 수를 이어 붙이면 새로운 수를 만들 수 있다. 다음 예를 보자. 26부터 시작한다. 2+6 = 8이다. 새로운 수는 68이다. 6+8 = 14이다. 새로운 수는 84이다. 8+4 = 12이다. 새로운 수는 42이다. 4+2 = 6이다. 새로운 수는 26이다. 위의 예는 4번만에 원래 수로 돌아올 수 있다. 따라서 26의 사이클의 길이는 4이다. N이 주어졌을 때, N의 사이클의 길이를 구하는 프로그램을 작성하시오. 입력 첫째 ..
[C++] cin.eof()와 EOF(End of file)
2020. 4. 28. 22:56
C++/공부
EOF EOF(End of File): 파일의 끝, 더 이상 읽을 데이터가 없다 cin으로 입력을 받으려고 할 때, EOF라면 입력이 취소되고 cin.eof()는 true를 반환한다. 이를 이용하여 파일이 종료될 때까지 입력을 받는 코드를 작성할 수 있다. 터미널(콘솔)에서는 EOF를 수동으로 넣어 주어야 한다. Windows: Ctrl+z / Unix: Ctrl+d 코드 #include int main() { using namespace std; int a, b; while(true) { cin >> a >> b; if (cin.eof()) break; cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FofEIG%2FbtqEj80kL4X%2F6qCJlkJ1jlLTRXSKYUG1p1%2Fimg.png)
[C++] 따라하며 배우는 C++ - (9) 연산자 오버로딩
2020. 4. 27. 21:44
C++/따라하며 배우는 C++
산술 연산자 오버로딩 하기 #include using namespace std; // 사용자 정의 자료형에서도 산술 연산자 정의 가능 class Cents { private: int m_cents; public: Cents(int cents = 0) { m_cents = cents; } int getCents() const { return m_cents; } int& getCents() { return m_cents; } //friend Cents operator + (const Cents &c1, const Cents &c2) //{ //return Cents(c1.getCents() + c2.getCents()); //} // friend 없애고 멤버 함수로 사용하려면... this 사용 // 멤버 ..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbR4Dt6%2FbtqDJgdguhH%2FQUVdwsofMqT5sXHLzTM7pK%2Fimg.png)
[Database] 데이터베이스 정규화(Normalization)
2020. 4. 26. 21:04
DB
정규화의 개요 정규화: 함수의 종속성을 이용하여 잘못 설계된 관계형 스키마를 더 작은 속성으로 쪼개는 과정, 데이터의 중복을 최소화로 줄이기 위함 데이터베이스의 논리적 설계 단계에서 수행한다. 정보의 무손실 표현: 정보의 손실이 있어서는 안 된다. 분리의 원칙: 독립된 관계성은 하나의 독립된 릴레이션으로 분리시켜야 한다. 데이터 중복성 감소 Anomaly(이상)의 개념 및 종류 Anomaly: 정규화를 거치지 않으면 불필요하게 중복된 데이터로 인해, 릴레이션 조작 시 예기치 못한 현상이 발생한다. 삽입 이상(Insertion Anomaly): 원치 않은 값도 함께 삽입해야 하는 현상 삭제 이상(Deletion Anomaly): 원치 않은 값도 함께 삭제되는 현상, 연쇄 삭제 현상 갱신 이상(Update ..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FRmHn8%2FbtqDXFj5CVn%2F0PDtrDheNzmQgGtDSl9yx1%2Fimg.png)
[C++] 따라하며 배우는 C++ - (8) 객체지향의 기초
2020. 4. 25. 02:37
C++/따라하며 배우는 C++
객체지향 프로그래밍과 클래스 #include #include #include using namespace std; // Friend: name, address, age, height, weight, ... void print(const string &name, const string &address, const int &age, const double &height, const double &weight) { cout
[특강] 왜? 내 게임은 완성되지 않을까?
2020. 4. 24. 22:22
게임 관련/특강
자기 자신을 알자 실력을 객관적으로 평가 잘할 수 있는 환경을 만드는 것도 실력임, 내가 원하는 100%의 환경이 만들어질 가능성은 매우 적음 => 뭐 때문에 능력치를 못 뽑아내는가? 다양한 것을 만들어 보기, 타인의 요구(협업?)에 맞게 장르적인 재미를 먼저 추구 액션 게임 => 적을 때리니 재미있음 플랫포머 => 돌아다니는 게 재미있음 슈팅 => 적을 맞추니 재미있음 시스템 늘어남 > 개발 기간 늘어남 > 계속 노잼 > 불만족 & 미완성 장르 베이스 + 새로운 요소 팀원을 구하려면 증명부터 능력, 경력 플레이 가능한 게임 테스트 게임? 처음부터 제대로 작은 메커니즘부터 살을 붙여서 다듬기보다는 컨텐츠 제작 완벽한 것은 존재하지 않음 => '자기만족'이 아닐지? 빠른 컨텐츠화 허접하더라도 실제 게임에서..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FQjBvy%2FbtqDQbKhcsG%2FOg8V9hNADJC5tPvhypLq21%2Fimg.png)
[C++] 따라하며 배우는 C++ - (7) 함수
2020. 4. 23. 17:10
C++/따라하며 배우는 C++
매개변수와 실인자의 구분 매개변수(Parameter) 인자(Argument) #include using namespace std; int foo(int x, int y); // parameter: 함수가 어떤 기능을 하는지, 바꿔 주는 역할 int foo(int x, int y) { // like... int x, y; return x + y; } // x and y are destroyed here, 함수가 끝남과 동시에 소멸됨 int main() { int x = 1, y = 2; foo(6, 7);// 6, 7: arguments (actual parameters) foo(x, y + 1);// x에 있는 값이 argument로, 함수의 parameter로 들어간다 // 항상 x에 있는 값만 전달되..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbSq2RJ%2FbtqDIn5alEx%2FY6ltKE4wSWCpgPkw0fIrQ0%2Fimg.png)
[C++] 따라하며 배우는 C++ - (6) 행렬, 문자열, 포인터, 참조
2020. 4. 22. 21:24
C++/따라하며 배우는 C++
배열 기초 array #include using namespace std; #define D_NUM_STUDENTS 100000 struct Rectangle { int length; int width; }; enum StudentName { JACKJACK,// = 0 DASH,// = 1 VIOLET,// = 2 NUM_STUDENTS,// = 3 }; int main() { /* int student1_score;// jack jack int student2_score;// dash int student3_score;// violet */ int one_student_score;// 1 variable int student_scores[5];// 5 int cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbCR1os%2FbtqDEZxovww%2F8ik6OtkgCeaGImqQFm9E5k%2Fimg.png)
[C++] 따라하며 배우는 C++ - (5) 흐름제어
2020. 4. 20. 21:57
C++/따라하며 배우는 C++
제어 흐름 개요 Control flow CPU가 해야 할 일을 조금 더 복잡하게 만들어 줄 수 있음, 흐름을 제어할 수 있음 순서도(Flow Chart) 1. 중단(Halt) 2. 점프(Jump): goto, break, continue 3. 조건 분기(Conditional branches): if, switch 4. 반복(루프)(Loops): while, do-while, for 5. 예외 처리(Exceptions): try, catch, throw #include #include // exit int main() { using namespace std; cout x; if (x > 10) { cout