본문 바로가기

전체 글333

[프로그래머스/C++] A 강조하기 문제문자열 myString이 주어집니다. myString에서 알파벳 "a"가 등장하면 전부 "A"로 변환하고, "A"가 아닌 모든 대문자 알파벳은 소문자 알파벳으로 변환하여 return 하는 solution 함수를 완성하세요. 솔루션#include #include #include using namespace std;string solution(string myString) { string answer = ""; for(int i = 0; i   메모테스트3에서 계속 틀렸는데"A"가 아닌 모든 대문자라는 부분을 간과해서 틀린거였다.. 힛 https://school.programmers.co.kr/learn/courses/30/lessons/181874 프로그래머스SW개발자를 위한 평가, 교육, .. 2025. 2. 14.
[프로그래머스/C++] 특정한 문자를 대문자로 바꾸기 문제영소문자로 이루어진 문자열 my_string과 영소문자 1글자로 이루어진 문자열 alp가 매개변수로 주어질 때, my_string에서 alp에 해당하는 모든 글자를 대문자로 바꾼 문자열을 return 하는 solution 함수를 작성해 주세요. 솔루션#include #include #include using namespace std;string solution(string my_string, string alp) { string answer = ""; for(int i = 0; i  https://school.programmers.co.kr/learn/courses/30/lessons/181873 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발.. 2025. 2. 14.
[프로그래머스/C++] 공백으로 구분하기 2 문제단어가 공백 한 개 이상으로 구분되어 있는 문자열 my_string이 매개변수로 주어질 때, my_string에 나온 단어를 앞에서부터 순서대로 담은 문자열 배열을 return 하는 solution 함수를 작성해 주세요. 솔루션#include #include using namespace std;vector solution(string my_string) { vector answer; string tmp = ""; for(int i = 0; i  https://school.programmers.co.kr/learn/courses/30/lessons/181868 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프progr.. 2025. 2. 14.
[프로그래머스/C++] 문자열 바꿔서 찾기 문제문자 "A"와 "B"로 이루어진 문자열 myString과 pat가 주어집니다. myString의 "A"를 "B"로, "B"를 "A"로 바꾼 문자열의 연속하는 부분 문자열 중 pat이 있으면 1을 아니면 0을 return 하는 solution 함수를 완성하세요. 솔루션#include #include #include using namespace std;int solution(string myString, string pat) { int answer = 0; string inverse = ""; for(int i = 0; i  https://school.programmers.co.kr/learn/courses/30/lessons/181864 프로그래머스SW개발자를 위한 평가, 교육, 채용까.. 2025. 2. 14.
[프로그래머스/C++] rny_string 문제'm'과 "rn"이 모양이 비슷하게 생긴 점을 활용해 문자열에 장난을 하려고 합니다. 문자열 rny_string이 주어질 때, rny_string의 모든 'm'을 "rn"으로 바꾼 문자열을 return 하는 solution 함수를 작성해 주세요. 솔루션#include #include using namespace std;string solution(string rny_string) { string answer = ""; for(int i = 0; i  https://school.programmers.co.kr/learn/courses/30/lessons/181863 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프progr.. 2025. 2. 14.
[프로그래머스/C++] 배열의 원소만큼 추가하기 문제아무 원소도 들어있지 않은 빈 배열 X가 있습니다. 양의 정수 배열 arr가 매개변수로 주어질 때, arr의 앞에서부터 차례대로 원소를 보면서 원소가 a라면 X의 맨 뒤에 a를 a번 추가하는 일을 반복한 뒤의 배열 X를 return 하는 solution 함수를 작성해 주세요.  솔루션#include #include using namespace std;vector solution(vector arr) { vector answer; for(int i = 0 ; i https://school.programmers.co.kr/learn/courses/30/lessons/181861 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠.. 2025. 2. 14.
[프로그래머스/C++] 배열의 길이에 따라 다른 연산하기 문제정수 배열 arr과 정수 n이 매개변수로 주어집니다. arr의 길이가 홀수라면 arr의 모든 짝수 인덱스 위치에 n을 더한 배열을, arr의 길이가 짝수라면 arr의 모든 홀수 인덱스 위치에 n을 더한 배열을 return 하는 solution 함수를 작성해 주세요. 솔루션#include #include using namespace std;vector solution(vector arr, int n) { vector answer; if(arr.size()%2!=0){ for(int i = 0; i  https://school.programmers.co.kr/learn/courses/30/lessons/181854 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total So.. 2025. 2. 14.
[프로그래머스/C++] 가장 큰 수 찾기 문제정수 배열 array가 매개변수로 주어질 때, 가장 큰 수와 그 수의 인덱스를 담은 배열을 return 하도록 solution 함수를 완성해보세요. 솔루션#include #include #include using namespace std;vector solution(vector array) { vector answer; vector tmp; tmp = array; sort(tmp.begin(), tmp.end()); answer.push_back(tmp[tmp.size()-1]); answer.push_back(distance(array.begin(), find(array.begin(), array.end(), tmp[tmp.size()-1]))); return .. 2025. 2. 14.
[프로그래머스/C++] 뒤에서 5등까지 문제정수로 이루어진 리스트 num_list가 주어집니다. num_list에서 가장 작은 5개의 수를 오름차순으로 담은 리스트를 return하도록 solution 함수를 완성해주세요. 솔루션#include #include #include using namespace std;vector solution(vector num_list) { vector answer; sort(num_list.begin(), num_list.end()); for(int i = 0 ; i  https://school.programmers.co.kr/learn/courses/30/lessons/181853 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이.. 2025. 2. 14.
[프로그래머스/C++] 정수 부분 문제실수 flo가 매개 변수로 주어질 때, flo의 정수 부분을 return하도록 solution 함수를 완성해주세요. 솔루션#include #include using namespace std;int solution(double flo) { return int(flo);} https://school.programmers.co.kr/learn/courses/30/lessons/181850 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 2025. 2. 14.