https://school.programmers.co.kr/learn/courses/30/lessons/12951
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
이게 왜 2단계인가 싶다 1단계 문제들 중에 어려운 문제 훨씬 많았는디...
#include <string>
#include <vector>
#include <ctype.h>
using namespace std;
string solution(string s) {
int first_flag = 1;
for (int i = 0; i < s.size(); i++) // 먼저 다 소문자로
{
if (s[i] >= 'A' && s[i] <= 'Z')
s[i] += 32;
}
for (int i = 0; i < s.size(); i++)
{
if (s[i] == ' ')
first_flag = 1;
if (first_flag)
{
if (s[i] == ' ')
continue ;
if (s[i] >= 'a' && s[i] <= 'z')
s[i] -= 32;
first_flag = 0;
}
}
return s;
}
'<algorithm> > 프로그래머스' 카테고리의 다른 글
프로그래머스 이진 변환 반복하기 c++ (0) | 2023.05.25 |
---|---|
프로그래머스 최댓값과 최솟값 c++ (0) | 2023.05.25 |
프로그래머스 신규 아이디 추천 c++ (2) | 2023.05.24 |
프로그래머스 성격 유형 검사하기 c++ (0) | 2023.05.24 |
프로그래머스 신고 결과 받기 c++ (0) | 2023.05.24 |