코딩테스트/프로그래머스 - LV 1
[프로그래머스] 이상한 문자 만들기
웅드
2024. 2. 9. 17:19
- 풀이
#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;
}
반응형