웅재의 코딩세상

[프로그래머스] 문자열의 뒤의 n글자 본문

코딩테스트/프로그래머스 - LV 0

[프로그래머스] 문자열의 뒤의 n글자

웅드 2024. 1. 23. 15:24

 

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

string solution(string my_string, int n) {
    string answer = "";
    for(int i=my_string.size()-n; i< my_string.size(); i++){
        answer += my_string[i];
    }
    return answer;
}
반응형