GameChoi
Choi Programming
GameChoi
전체 방문자
오늘
어제
  • 분류 전체보기 (468)
    • C++ Algorithm & Study (184)
      • C++ & Algorithm Strategies (45)
      • Game Math & DirectX 11 (72)
      • Server + UE5 (29)
      • Lyra Clone Coding (37)
    • Create Game (284)
      • [Window API] Game Client & .. (55)
      • [DirectX] DirectX 2D & 3D (155)
      • [UE5] BLUEPRINT & C++ (74)
    • odds and ends (0)
      • English (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Network Worker
  • Direct3D
  • c++
  • job queue
  • server
  • protobuf
  • RPG Game
  • Algorithm Strategies
  • core
  • Destination Move Packet
  • Player State
  • Direct11
  • UE5
  • GAME Client
  • Other Character
  • Game Room
  • client
  • Game Server
  • session
  • Player Move Packet

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
GameChoi

Choi Programming

[Programmers] 이상한 문자 만들기
C++ Algorithm & Study/C++ & Algorithm Strategies

[Programmers] 이상한 문자 만들기

2023. 1. 16. 20:40

https://school.programmers.co.kr/learn/courses/30/lessons/12930

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

0. Headers

#include <string>
using namespace std;

1. 알고리즘

 - 짝수는 대문자, 홀수는 소문자로 만들어야 하므로 toupper, tolower 함수 사용

   - 공백이 나올경우 index 초기화

string solution(string s) {
    for (auto st : s)
    {
        if (st == ' ') { str.push_back(' '); index = 0; continue; }
        else (index % 2 == 0) ? str.push_back(toupper(st)) : str.push_back(tolower(st));
        index++;
    }
    return str;
}

2. 완성 코드

#include <string>
using namespace std;

string solution(string s) {
    int index = 0;
    string str = "";
    
    for (auto st : s)
    {
        if (st == ' ') { str.push_back(' '); index = 0; continue; }
        else (index % 2 == 0) ? str.push_back(toupper(st)) : str.push_back(tolower(st));
        index++;
    }
    return str;
}

저작자표시 (새창열림)

'C++ Algorithm & Study > C++ & Algorithm Strategies' 카테고리의 다른 글

[Programmers] 카펫  (0) 2023.01.21
[Programmers] 구명보트  (0) 2023.01.17
[Programmers] 예상 대진표  (0) 2023.01.10
[Programmers] 점프와 순간 이동  (0) 2023.01.09
[Programmers] 삼총사  (0) 2023.01.07
    'C++ Algorithm & Study/C++ & Algorithm Strategies' 카테고리의 다른 글
    • [Programmers] 카펫
    • [Programmers] 구명보트
    • [Programmers] 예상 대진표
    • [Programmers] 점프와 순간 이동
    GameChoi
    GameChoi

    티스토리툴바