목록전체 글 (718)
N
https://school.programmers.co.kr/learn/courses/30/lessons/340213 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr #include #include #include using namespace std;vector splitTime(string time) { vector tokens; size_t pos = 0; string token; string delimiter = ":"; while ((pos = time.find(delimiter)) != string::npos) { token = time.substr(0, po..
https://school.programmers.co.kr/learn/courses/30/lessons/389478 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 복잡하게 공식을 찾아내는 것보다,brute force로 하는게 더 빠르다고 느낀 문제. 문제의 핵심은 순서대로 숫자를 늘릴지, 역순으로 숫자를 늘릴지인 것 같다. #include #include using namespace std;int getFloor(int n, int w) { return (n / w) + (n % w == 0 ? 0 : 1);}int solution(int n, int w, int num) { int answer = ..
https://school.programmers.co.kr/learn/courses/30/lessons/258712?language=cpp 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr #include #include #include #include #include using namespace std;int solution(vector friends, vector gifts) { int answer = 0; map> history; // giver : (taker, count) map> score; // name : (give, take) // initialize the histor..
https://school.programmers.co.kr/learn/courses/30/lessons/340203 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 주어진 cpr과 basic_order를 순회하면서 같은 값이면 해당 인덱스 값을 +1 해서 answer에 있는 값을 바꿔주는 문제.#include #include using namespace std;vector solution(vector cpr) { vector answer = {0, 0, 0, 0, 0}; vector basic_order = {"check", "call", "pressure", "respiration", "repeat"..
https://school.programmers.co.kr/learn/courses/30/lessons/340204 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 빈칸을 채워서 푸는 문제.각 조건에 따라 출력되는 값이 다르게 나온다.출력되는 값을 보고 조건을 넣어주면 된다.#include using namespace std;int main(void) { string code; cin >> code; string last_four_words = code.substr(code.size()-4, 4); if(last_four_words == "_eye") { // 빈칸 cout
https://school.programmers.co.kr/learn/courses/30/lessons/340205 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 필요없는 for문에서 while문으로 수정.number가 1 이상일 때까지 반복해서 값을 더해주면 된다.#include using namespace std;int main(void) { int number; cin >> number; int answer = 0; while (number) { // for문 -> while문으로 수정 answer += number % 100; number /=..
https://school.programmers.co.kr/learn/courses/30/lessons/340206 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 프로그래머스에 신기한 문제가 추가되었다.디버깅을 해서 1 라인만 수정하는 문제. 두 값을 더해서 360으로 나눴을 때 나머지를 출력해주면 된다.#include using namespace std;int main(void) { int angle1; int angle2; cin >> angle1 >> angle2; int sum_angle = (angle1 + angle2) % 360; // 수정한 라인 cout
https://school.programmers.co.kr/learn/courses/30/lessons/181829 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 처음 문제를 접했을 때는 단순하게 모든 배열을 순회하면서 조건에 부합하면 값을 더해주는 걸 떠올렸다.chat gpt 역시 이 방법을 사용했다. 문제에서는 아래와 같은 제한사항이 있기 때문에, '굳이 모든 배열을 순회하지 않고 loop의 범위를 제한할 수 있겠다' 라는 생각이 들었다.1 ≤ board의 길이 ≤ 1001 ≤ board[i]의 길이 ≤ 1001 ≤ board[i][j] ≤ 10,000모든 board[i]의 길이는 같습니다.0 ≤ k 가독..