https://school.programmers.co.kr/learn/courses/30/lessons/340213
ํ๋ก๊ทธ๋๋จธ์ค
SW๊ฐ๋ฐ์๋ฅผ ์ํ ํ๊ฐ, ๊ต์ก, ์ฑ์ฉ๊น์ง Total Solution์ ์ ๊ณตํ๋ ๊ฐ๋ฐ์ ์ฑ์ฅ์ ์ํ ๋ฒ ์ด์ค์บ ํ
programmers.co.kr
ํ๋ก๊ทธ๋๋จธ์ค ๋ ๋ฒจ 1..์์๋ ๋ถ๊ตฌํ๊ณ ์ ๋ต๋ฅ ์ด 37%๋ก ๊ฝค๋ ๋ฎ์ ๋ฌธ์ .
์์์๊ฐ ์ฝ 22๋ถ
๊ธฐ๋ณธ์ ์ธ ๋ฌธ์์ด ๋ค๋ฃจ๊ธฐ ๋ฌธ์ ์ด์ง๋ง,
์คํ๋ ค ์์ฃผ ๊ธฐ์ด์ ์ธ ๋ฌธ๋ฒ์ ๋ค๋ค์ผ ํ๊ธฐ ๋๋ฌธ์
์๊ณ ์์๋ ๋ด์ฉ๋ ์์๊ณ ๋ง์ด ํท๊ฐ๋ ค์ ์๊ฐ๋ณด๋ค ์ค๋ ๊ฑธ๋ ธ๋ค ใ ใ ๊ผญ ๊ธฐ์ตํด๋๊ธฐ~~!!!!
(c++ ๊ธฐ์ค ํด๊ฒฐ๋ฐฉ๋ฒ)
์๊ฐ์ ๋ชจ๋ ์ด ๋จ์๋ก ๋ฐ๊ฟ์ค ๋, ๊ฐ ๋ฌธ์๋ง๋ค [ ๋ฌธ์-'0' ]์ ํด์ค ๋ค์ ์ฐ์ฐํด์ผ ํ๊ณ
๋ํ ๋๋ string์ผ๋ก [๋ฌธ์+'0']์ ์ฐ์ฐํด์ฃผ๊ฑฐ๋, to_string์ ์ฌ์ฉํด์ผ ํ๋ค.
1๏ธโฃ string์ผ๋ก ๋ช ์์ ํ๋ณํ
answer += string(1, h/10+'0') + string(1, h%10+'0');
answer += to_string(h / 10) + to_string(h % 10);
๋์ ํ์ด
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int timeToSec(string t) {
return ((t[0]-'0')*10 + (t[1]-'0'))*60 + ((t[3]-'0')*10+(t[4]-'0'));
}
string solution(string video_len, string pos, string op_start, string op_end, vector<string> commands) {
string answer = "";
int len = timeToSec(video_len);
int nowSec = timeToSec(pos);
int opStart = timeToSec(op_start);
int opEnd = timeToSec(op_end);
for(string command: commands){
if(nowSec >= opStart && nowSec < opEnd) nowSec = opEnd;
if(command == "next"){
nowSec += 10;
if(nowSec > len) nowSec = len;
}
if(command == "prev"){
nowSec -= 10;
if(nowSec < 0) nowSec = 0;
}
}
if(nowSec >= opStart && nowSec < opEnd) nowSec = opEnd;
int h = nowSec/60;
int m = nowSec%60;
answer += to_string(h / 10) + to_string(h % 10);
answer += ":";
answer += to_string(m / 10) + to_string(m % 10);
return answer;
}
'๐ ์๊ณ ๋ฆฌ์ฆ > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++/PGS] Lv.4 : ์ง๊ฒ๋ค๋ฆฌ (์ด๋ถํ์) (0) | 2025.05.03 |
---|---|
[C++/PGS] Lv.3 : ์์ ๋ณต์ํ๊ธฐ (PCCP ๊ธฐ์ถ๋ฌธ์ 4๋ฒ) - ๋ณด๋ฅ๐ฅต (0) | 2025.05.02 |
[C++/PGS] [PCCP ๊ธฐ์ถ๋ฌธ์ ] 4๋ฒ - ์๋ ์์ง์ด๊ธฐ (1) | 2025.05.02 |
[C++/PGS] [PCCP ๊ธฐ์ถ๋ฌธ์ ] 1๋ฒ - ๋ถ๋ ๊ฐ๊ธฐ (0) | 2025.05.02 |
[C++/PGS] [PCCP ๋ชจ์๊ณ ์ฌ #1] 3๋ฒ - ์ ์ ๋ฒ์น ๐คฏ (0) | 2025.05.02 |