baekjoon 2675

윤동환·2022년 12월 1일
0

Algorithm

목록 보기
16/54

문자열 반복

내가 작성한 코드

#include <iostream>

using namespace std;

string newString(int r, string s) {
    string n;
    int len = s.length();
    for (int i = 0; i < len; ++i) {
        for (int j = 0; j < r; ++j) {
            n += s[i];
        }
    }
    return n;
}

int main() {
    int count;
    int repeat;
    string ret;
    string S;
    cin >> count;
    for (int i = 0; i < count; ++i) {
        cin >> repeat >> S;
        ret = newString(repeat, S);
        cout << ret << endl;
    }
    return (0);
}
profile
모르면 공부하고 알게되면 공유하는 개발자

0개의 댓글