알고리즘/프로그래머스

Programers JadenCase 문자열 만들기 / C++

내이름은 킹햄찌 2022. 12. 3. 14:16

https://school.programmers.co.kr/learn/courses/30/lessons/12951

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

아이디어

문자열 처리 문제입니다 toupper, tolower 함수를 이용했습니다.

 

#include <string>
#include <vector>

using namespace std;

string solution(string s) {
    string answer = "";
    answer += toupper(s[0]);
    for(int i=1;i<s.size();i++){
        if(s[i-1] == ' '){
            answer += toupper(s[i]);
            continue;
        }
        answer += tolower(s[i]);
    }
    return answer;
}