전체 글333 [프로그래머스/C++] 자릿수 더하기 문제정수 n이 매개변수로 주어질 때 n의 각 자리 숫자의 합을 return하도록 solution 함수를 완성해주세요 솔루션#include #include using namespace std;int solution(int n) { int answer = 0; while(1){ answer += n%10; n /= 10; if(n==0){ return answer; } } return answer;} https://school.programmers.co.kr/learn/courses/30/lessons/120906 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 .. 2025. 2. 12. [프로그래머스/C++] 문자열 곱하기 문제문자열 my_string과 정수 k가 주어질 때, my_string을 k번 반복한 문자열을 return 하는 solution 함수를 작성해 주세요. 솔루션#include #include using namespace std;string solution(string my_string, int k) { string answer = ""; for(int i = 0; i https://school.programmers.co.kr/learn/courses/30/lessons/181940 2025. 2. 12. [프로그래머스/C++] 피자 나눠 먹기 (1) 문제머쓱이네 피자가게는 피자를 일곱 조각으로 잘라 줍니다. 피자를 나눠먹을 사람의 수 n이 주어질 때, 모든 사람이 피자를 한 조각 이상 먹기 위해 필요한 피자의 수를 return 하는 solution 함수를 완성해보세요. 솔루션#include #include using namespace std;int solution(int n) { int answer = 0; if(n%7==0){ return n/7; } else{ return n/7+1; } return answer;} https://school.programmers.co.kr/learn/courses/30/lessons/120814 2025. 2. 12. [프로그래머스/C++] 머쓱이보다 키 큰 사람 문제머쓱이는 학교에서 키 순으로 줄을 설 때 몇 번째로 서야 하는지 궁금해졌습니다. 머쓱이네 반 친구들의 키가 담긴 정수 배열 array와 머쓱이의 키 height가 매개변수로 주어질 때, 머쓱이보다 키 큰 사람 수를 return 하도록 solution 함수를 완성해보세요. 솔루션#include #include #include using namespace std;int solution(vector array, int height) { int answer = 0; answer = count_if(array.begin(), array.end(), [&](int x){return x > height;}); return answer;} https://school.programmers.co.kr/.. 2025. 2. 12. [프로그래머스/C++] 배열의 유사도 문제두 배열이 얼마나 유사한지 확인해보려고 합니다. 문자열 배열 s1과 s2가 주어질 때 같은 원소의 개수를 return하도록 solution 함수를 완성해주세요. 솔루션#include #include #include using namespace std;int solution(vector s1, vector s2) { int answer = 0; for(int i = 0; i https://school.programmers.co.kr/learn/courses/30/lessons/120903 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 2025. 2. 12. [프로그래머스/C++] n의 배수 고르기 문제정수 n과 정수 배열 numlist가 매개변수로 주어질 때, numlist에서 n의 배수가 아닌 수들을 제거한 배열을 return하도록 solution 함수를 완성해주세요. 솔루션#include #include using namespace std;vector solution(int n, vector numlist) { vector answer; for(int i = 0; i https://school.programmers.co.kr/learn/courses/30/lessons/120905 2025. 2. 12. [프로그래머스/C++] 삼각형의 완성조건 (1) 문제선분 세 개로 삼각형을 만들기 위해서는 다음과 같은 조건을 만족해야 합니다.-가장 긴 변의 길이는 다른 두 변의 길이의 합보다 작아야 합니다. 삼각형의 세 변의 길이가 담긴 배열 sides이 매개변수로 주어집니다. 세 변으로 삼각형을 만들 수 있다면 1, 만들 수 없다면 2를 return하도록 solution 함수를 완성해주세요. 솔루션#include #include #include using namespace std;int solution(vector sides) { int answer = 0; sort(sides.begin(), sides.end()); if(sides[0]+sides[1]>sides[2]) return 1; else return 2;.. 2025. 2. 12. [프로그래머스/C++] 아이스 아메리카노 문제머쓱이는 추운 날에도 아이스 아메리카노만 마십니다. 아이스 아메리카노는 한잔에 5,500원입니다. 머쓱이가 가지고 있는 돈 money가 매개변수로 주어질 때, 머쓱이가 최대로 마실 수 있는 아메리카노의 잔 수와 남는 돈을 순서대로 담은 배열을 return 하도록 solution 함수를 완성해보세요. 솔루션#include #include using namespace std;vector solution(int money) { vector answer; answer.push_back(money/5500); answer.push_back(money%5500); return answer;} https://school.programmers.co.kr/learn/courses/30/lesso.. 2025. 2. 12. [프로그래머스/C++] 점의 위치 구하기 문제사분면은 한 평면을 x축과 y축을 기준으로 나눈 네 부분입니다. 사분면은 아래와 같이 1부터 4까지 번호를매깁니다. -x 좌표와 y 좌표가 모두 양수이면 제1사분면에 속합니다. -x 좌표가 음수, y 좌표가 양수이면 제2사분면에 속합니다. -x 좌표와 y 좌표가 모두 음수이면 제3사분면에 속합니다. -x 좌표가 양수, y 좌표가 음수이면 제4사분면에 속합니다. x 좌표 (x, y)를 차례대로 담은 정수 배열 dot이 매개변수로 주어집니다. 좌표 dot이 사분면 중 어디에 속하는지 1, 2, 3, 4 중 하나를 return 하도록 solution 함수를 완성해주세요. 솔루션#include #include using namespace std;int solution(vector dot) { int x.. 2025. 2. 12. [프로그래머스/C++] 문자열 뒤집기 문제문자열 my_string이 매개변수로 주어집니다. my_string을 거꾸로 뒤집은 문자열을 return하도록 solution 함수를 완성해주세요. 솔루션#include #include #include using namespace std;string solution(string my_string) { string answer = ""; reverse(my_string.begin(), my_string.end()); return my_string;} https://school.programmers.co.kr/learn/courses/30/lessons/120822 2025. 2. 12. 이전 1 ··· 10 11 12 13 14 15 16 ··· 34 다음