본문 바로가기
C++

[프로그래머스] 뒤집힌 문자열

by 띰쥬 2025. 9. 2.
728x90
반응형
SMALL

#include <string>
#include <vector>

using namespace std;

string solution(string my_string) {
    string answer = "";
    for(int i=my_string.size(); i>0; i--)
        answer.push_back(my_string.at(i-1));
    return answer;
}

 

 

*rbegin(),rend() 메소드 사용하면 한줄로 리턴 가능

728x90
반응형
LIST

'C++' 카테고리의 다른 글

[프로그래머스] 세균증식  (0) 2025.09.03
[프로그래머스] 편지  (0) 2025.09.02
[프로그래머스] 짝수 홀수 개수  (0) 2025.09.02
[프로그래머스] 배열 뒤집기  (0) 2025.09.02
[프로그래머스] 짝수의 합  (0) 2025.09.02

댓글