12930번 이상한 문자 만들기
2023. 3. 21. 14:25ㆍProgrammers
코딩테스트 연습 - Level 1 - 이상한 문자 만들기
https://programmers.co.kr/learn/courses/30/lessons/12930
#include <string>
#include <vector>
using namespace std;
string solution(string s) {
string answer = "";
int index=0;
for(int i=0;i<s.size();i++)
{
if(s[i]==' ')
{
index=0;
continue;
}
if(index%2==1)
{
if('A'<=s[i]&&s[i]<='Z')
{
s[i]+=32;
}
}
else
{
if('a'<=s[i]&&s[i]<='z')
{
s[i]-=32;
}
}
index++;
}
return s;
}
🔊공백 주의
'Programmers' 카테고리의 다른 글
12926번 시저 암호 (0) | 2023.03.21 |
---|---|
12928번 약수의 합 (0) | 2023.03.21 |
12931번 자릿수 더하기 (0) | 2023.03.21 |
12932번 자연수 뒤집어 배열로 만들기 (0) | 2023.03.21 |
12933번 정수 내림차순으로 배치하기 (0) | 2023.03.21 |