본문 바로가기

C++197

[C++20 - Language] Chapter 04. Conditionally Explicit Constructor (조건부 Explicit 생성자) GitHub : https://github.com/developeSHG/CPP20-Language/commit/522ca880fd24d6328a350e1d6f5454d763eaf260 Conditionally Explicit Constructor (조건부 Explicit 생성자) · developeSHG/CPP20-Language@522ca88 developeSHG committed Jul 27, 2023 github.com #include using namespace std; #include #include #include #include #include #include #include // 오늘의 주제 : Conditionally Explicit Constructor (조건부 Explicit 생성자).. 2023. 7. 28.
[C++20 - Language] Chapter 03. consteval / constinit GitHub : https://github.com/developeSHG/CPP20-Language/commit/d46afb5381c4bd788477d95c80b018f43bb9ca85 consteval / constinit · developeSHG/CPP20-Language@d46afb5 developeSHG committed Jul 27, 2023 github.com consteval, constinit // const 들을 비교해보기 전에 밑의 개념을 알고가자. // 컴파일 타임 vs 런타임 // 컴파일 -> 실행파일(exe) -> 런타임 // 정리하자면 C++ 코드를 컴파일러가 번역해서 바이너리 파일로 만들어 준 후, // 경과물들을 링크 단계를 거쳐서 최종적으로 실행파일을 만들게 된다. // 그리.. 2023. 7. 28.
[C++20 - Language] Chapter 02. Designated Initialization (지정 초기화) GitHub : https://github.com/developeSHG/CPP20-Language/commit/d3b68fe794104dd00e3242e26efde06e206fb046 Designated Initialization (지정 초기화) · developeSHG/CPP20-Language@d3b68fe developeSHG committed Jul 27, 2023 github.com #include using namespace std; #include #include #include #include #include #include #include // 오늘의 주제 : Designated Initialization (지정 초기화) struct Pos2D { int x; int y; }; class.. 2023. 7. 28.
[Programmers] Lv 2. 124 나라의 숫자 https://school.programmers.co.kr/learn/courses/30/lessons/12899 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; string solution(int n) { string answer = "", str = "412"; while (n) { answer = str[n % 3] + answer; if (n % 3 == 0) --n; // 3인 경우는 4로 표현하기 때문에 -1 n = n / 3; } return answer; } GitHub :.. 2023. 7. 28.
[Programmers] (월간 코드 챌린지 시즌1) Lv 2. 삼각 달팽이 https://school.programmers.co.kr/learn/courses/30/lessons/68645 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; vector solution(int n) { vector vec; const size_t size = n * (n + 1) / 2; // n = 4 => 1+2+3+4 = 10 size_t row = 0, col = 0, count = 1; /* n = 4 일 때 다음 배열을 먼저 생성 [ [0].. 2023. 7. 28.
[Programmers] (탐욕법(Greedy)) Lv 2. 큰 수 만들기 https://school.programmers.co.kr/learn/courses/30/lessons/42883 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; string solution(string number, int k) { string answer = ""; int start = 0, cnt = number.length() - k; while (answer.length() != cnt) { // end에서 구해야 할 남은 개수만큼 뺀 영역까지 최.. 2023. 7. 27.
[C++20 - Language] Chapter 01. Three-Way Comparison 연산자 (Spaceship Operator <=> ) GitHub :https://github.com/developeSHG/CPP20-Language/commit/f711b3b8cfbbd4f83d077c81743b4a034b47ba83 Three-Way Comparison 연산자 (Spaceship Operator ) · developeSHG/CPP20-Language@f711b3b developeSHG committed Jul 27, 2023 github.com // = == != // 보통 = == != // 보통 < 로 연산자 오버로딩을 하면 위의 수식도 필요한게 일반적. // 저것을 다 정의하는 것보다, 알아서 자동으로 해줄 수 있게 지원하는 게 Spaceship Operator bool operator b; bool test3 = a b 중 하나는.. 2023. 7. 26.
[Programmers] Lv 2. 택배상자 https://school.programmers.co.kr/learn/courses/30/lessons/131704 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(vector order) { int answer = 0; stack s; priority_queue q(order.begin(), order.end()); for (size_t i = 0; i < order.size();) { const auto find = order[i.. 2023. 7. 26.
[C++20 - 4th Emperor] Chapter 04. Coroutine GitHub : https://github.com/developeSHG/CPP20-4th_Emperor/commit/19ff2673e96a446bee711c99873b180d69b52391 Coroutine · developeSHG/CPP20-4th_Emperor@19ff267 developeSHG committed Jul 26, 2023 github.com Module 기능과 함께 가장 중요한 기능인 Coroutine // 유니티 = 코루틴 // - C#에서 있는 코루틴 문법을 유니티에서 적극적으로 채용해서 제공 어떤 함수를 호출할 때, 함수를 어디까지 진행했는지 저장하고, 일시정지했다가 다시 이어서 호출할 수 있는 기능 간단히 말해서 내가 원할 때, 핸들을 이용해 코드를 다시 재게하거나 제거해버리는 .. 2023. 7. 25.
[C++20 - 4th Emperor] Chapter 03. Range GitHub : https://github.com/developeSHG/CPP20-4th_Emperor/commit/f7e318d8e7ff816fc029ec7544e8191798030035 Range · developeSHG/CPP20-4th_Emperor@f7e318d developeSHG committed Jul 25, 2023 github.com C# LINQ 문법이랑 비슷하다. #include using namespace std; #include #include #include #include #include // Range #include // 오늘의 주제 : Range template requires std::ranges::view // concept 문법 class ContainerView .. 2023. 7. 25.