프로그래머스(Programmers)
Level 2 > JadenCase
cepiloth
2018. 8. 22. 13:19
반응형
https://programmers.co.kr/learn/courses/30/lessons/12951
1. 문제
문장에 첫 글자를 대문자 나머지는 소문자로 변환하는 문제
2. 알고리즘
키워드 - 문자열
3. 코드
1 2 3 4 5 6 7 8 9 10 11 | #include <string> #include <vector> using namespace std; string solution(string s) { s.at(0) = toupper(s.at(0)); for (int i = 1; i < s.length(); i++) s.at(i) = (s.at(i - 1) == ' ') ? toupper(s.at(i)) : tolower(s.at(i)); return s; } | cs |
반응형