Notice
Recent Posts
Recent Comments
Today
Total
01-10 22:06
Link
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Partially Committed

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ด์ƒํ•œ ๋ฌธ์ž ๋งŒ๋“ค๊ธฐ ๋ณธ๋ฌธ

๐Ÿ”ฅ Algorithm || ๋ฌธ์ œํ’€์ด/PS

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ด์ƒํ•œ ๋ฌธ์ž ๋งŒ๋“ค๊ธฐ

WonderJay 2022. 7. 6. 23:39
728x90
๋ฐ˜์‘ํ˜•
SMALL

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

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

๋‹จ์–ด ์‚ฌ์ด์— ๊ณต๋ฐฑ์ด ์—ฌ๋Ÿฌ ๊ฐœ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์— ์ฃผ์˜ํ•˜์ž!

( ๋‹จ์–ด ์‚ฌ์ด๋Š” ๋ฌด์กฐ๊ฑด ๊ณต๋ฐฑ์ด ํ•˜๋‚˜์ผ ์ค„ ์•Œ๊ณ , stringstream ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋‹ค๊ฐ€ ํ•œ์ฐธ๋™์•ˆ ๋งž์™œํ‹€ ํ•ด๋ฒ„๋ ธ๋‹ค. )

 

 

[C++]

#include <bits/stdc++.h>
#define fastio cin.tie(0)->sync_with_stdio(0)
#define ll long long
using namespace std;


string solution(string s) {
    string answer = "";

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == ' ')
        {
            continue;
        }
        else
        {
            for (int k = 0; k < s.size() && i < s.size(); k++, i++)
            {
                if (s[i] == ' ') break;
                if (k % 2 == 0) s[i] = toupper(s[i]);
                else if (k % 2 == 1) s[i] = tolower(s[i]);
            }
        }
    }
    answer = s;
    return answer;
}

 

728x90
๋ฐ˜์‘ํ˜•
LIST
Comments