웅재의 코딩세상
[프로그래머스] 이상한 문자 만들기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
string solution(string s) {
string answer = "";
int k=1;
for(int i=0; i<s.size(); i++){
if(s[i] == ' ') {
k=0;
}
if(k%2 ==1){
answer.push_back(toupper(s[i]));
k++;
}
else{
answer.push_back(tolower(s[i]));
k++;
}
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 문자열을 정수로 바꾸기 (0) | 2024.02.09 |
---|---|
[프로그래머스] 약수의 합 (0) | 2024.02.09 |
[프로그래머스] 자릿수 더하기 (0) | 2024.02.09 |
[프로그래머스] 자연수 뒤집어 배열로 만들기 (0) | 2024.02.09 |
[프로그래머스] 정수 내림차순으로 배치하기 (0) | 2024.02.09 |