https://github.com/GyungSikHan/AlgorithmTest/tree/main/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4/2/12951.%E2%80%85JadenCase%E2%80%85%EB%AC%B8%EC%9E%90%EC%97%B4%E2%80%85%EB%A7%8C%EB%93%A4%EA%B8%B0

#include <string>
#include <vector>
#include <ctype.h>

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]);
        else
            answer += tolower(s[i]);
    }

    return answer;
}
  • toupper은 문자를 대문자로 바꿔주는 함수
  • tolower은 문자를 소문자로 바꿔주는 함수
  • 이 두 함수는 ctype 헤더안에 있는 함수로 이를 이용하면 쉽게 구할 수 있는 문제였다

'코딩 태스트 > 문제풀이' 카테고리의 다른 글

피보나치 수 - 12945  (0) 2025.03.13
이진 변환 반복하기 - 70129  (0) 2025.03.11
최댓값과 최솟값 - 12939  (0) 2025.03.10
괄호 추가하기  (0) 2025.02.05
뮤탈리스크  (0) 2025.02.05