Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 그래프
- vector
- 프로그래머스
- 깊이우선탐색
- stoi
- DP
- 유클리드호제법
- 티스토리챌린지
- priority_queue
- 이분탐색
- int
- DFS
- 백준
- 정렬
- N과M
- 배열
- 에라토스테네스의 체
- 최소공배수
- 분할정복
- 오블완
- C++
- 다이나믹프로그래밍
- 우선순위큐
- 백트래킹
- BFS
- 문자열
- Sort
- 알고리즘
- map
- Set
Archives
- Today
- Total
안녕 세상아,
[c++/프로그래머스] LV2 JadenCase 문자열 만들기 본문
https://school.programmers.co.kr/learn/courses/30/lessons/12951
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string solution(string s) {
//check가 true인 상태일 때 (공백 다음에 나오는 문자)
int i = 0;
bool check = true; //맨 처음 나오는 단어에 대응
while (s[i]) {
//공백일 경우 넘어감
if (s[i] == ' ') {
check = true;
i++;
continue;
}
else
{
//공백이 아닌 문자를 만났을 경우
//1. 첫번째 문자
if (check) {
s[i] = toupper(s[i]);
check = false;
}
//2. 첫번째가 아닌 문자
else
{
s[i] = tolower(s[i]);
check = false;
}
i++;
}
}
return s;
}
// 출력값 확인을 위해
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str;
getline(cin, str);
cout<<solution(str);
}
'프로그래머스' 카테고리의 다른 글
[c++/프로그래머스] N개의 최소공배수 (0) | 2023.08.31 |
---|---|
[c++] 구명보트 (0) | 2023.08.17 |
[c++/프로그래머스] LV 2 카펫 (0) | 2023.06.27 |
[c++/프로그래머스] LV2 최솟값 만들기 (0) | 2023.05.08 |
[c++/프로그래머스] LV2 최댓값과 최솟값 (1) | 2023.05.05 |