문제
풀이
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(string s) {
string tmp;
for (int i = 0; i < s.size(); i++)
{
if (isdigit(s[i]) != 0)
continue;
tmp.clear();
if (i == 0 || s[i - 1] == ' ')
{
if (s[i] - '0' >= 'a' || s[i] - '0' <= 'z')
{
tmp = toupper(s[i]);
s.replace(i, 1, tmp);
continue;
}
}
tmp = tolower(s[i]);
s.replace(i, 1, tmp);
}
return s;
}
결과
걸린 시간
1시간
'개발 > 알고리즘' 카테고리의 다른 글
조합 알고리즘 C++ (0) | 2021.01.02 |
---|---|
프로그래머스 다음 큰 숫자 C++ (0) | 2021.01.01 |
프로그래머스 튜플 C++ (0) | 2020.12.22 |
프로그래머스 피보나치 수 C++ (0) | 2020.12.15 |
프로그래머스 N개의 최소공배수 (0) | 2020.12.15 |