문제
문자열 my_string과 정수 k가 주어질 때, my_string을 k번 반복한 문자열을 return 하는 solution 함수를 작성해 주세요.
솔루션
#include <string>
#include <vector>
using namespace std;
string solution(string my_string, int k) {
string answer = "";
for(int i = 0; i < k; i++)
answer += my_string;
return answer;
}
https://school.programmers.co.kr/learn/courses/30/lessons/181940
'프로그래머스코딩테스트연습풀이 > C++' 카테고리의 다른 글
[프로그래머스/C++] n의 배수 (0) | 2025.02.12 |
---|---|
[프로그래머스/C++] 자릿수 더하기 (0) | 2025.02.12 |
[프로그래머스/C++] 피자 나눠 먹기 (1) (0) | 2025.02.12 |
[프로그래머스/C++] 머쓱이보다 키 큰 사람 (0) | 2025.02.12 |
[프로그래머스/C++] 배열의 유사도 (0) | 2025.02.12 |