코딩테스트/프로그래머스
[Level 1][C++] 가운데 글자 가져오기
MJ.Lee
2024. 9. 27. 22:53
#include <string>
#include <vector>
using namespace std;
string solution(string s) {
string answer = "";
if(s.length()%2==0)
answer += s.at(s.length()/2-1); // at 함수. 문자열 내 특정 위치에 있는 문자를 반환한다.
answer += s.at(s.length()/2);
return answer;
}