#include <string>
#include <cstring>
#include <cctype>
using namespace std;
string solution(string s) {
int count = 1;
char * arr = new char[s.length() + 1];
strcpy(arr, s.c_str());
for (int i = 0; i < s.length(); i++)
{
if (arr[i] == ' ')
{
count = 1;
continue;
}
if (count % 2 == 1)
{
if (islower(arr[i])) //헤더 cctype에 있는 소문자인지 판별하는 함수
arr[i] = toupper(arr[i]); //헤더 cctype에 있는 대문자로 변환하는 함수
}
else
{
if (isupper(arr[i])) //대문자인지 판별하는 함수
arr[i] = tolower(arr[i]); //소문자로 변환하는 함수
}
count++;
}
string answer(arr);
return answer;
}
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[Level 1][C++] K번째 수 (0) | 2024.10.01 |
---|---|
[Level 1][C++] 문자열 내 마음대로 정렬하기 (0) | 2024.10.01 |
[Level 1][C++] 자릿수 더하기 (0) | 2024.09.30 |
[Level 1][C++] 최대공약수와 최소공배수 (0) | 2024.09.30 |
[Level 1][C++] 정수 제곱근 판별 (0) | 2024.09.30 |