프로그래머스

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 수 조작하기 2

문제 코드 #include #include using namespace std; string solution(vector numLog) { string answer = ""; int currentNum = 0; int prevNum = 0; int result = 0; for (int i = 0; i < numLog.size(); ++i) { if (i == 0) { currentNum = numLog[i]; prevNum = numLog[i]; } else { prevNum = numLog[i - 1]; } currentNum = numLog[i]; result = currentNum - prevNum; switch (result) { case 1:answer += "w"; break; case -1:..

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 수 조작하기 1

문제 코드 #include #include using namespace std; int solution(int n, string control) { int answer = n; for (const char c : control) { if (c == 'w') { answer += 1; } if (c == 's') { answer -= 1; } if (c == 'd') { answer += 10; } if (c == 'a') { answer -= 10; } } return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 마지막 두 원소

문제 코드 #include using namespace std; vector solution(vector num_list) { vector answer; for (int i = 0; i num_list[i - 1]) { answer.emplace_back(num_list[i] - num_list[i - 1]); } else { answer.emplace_back(num_list[i] * 2); } } } return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 이어 붙인 수

문제 코드 #include #include using namespace std; int solution(vector num_list) { int answer = 0; string even; string odd; for (const int n : num_list) { if (n % 2 == 0) { even += (to_string(n)); } else { odd += (to_string(n)); } } answer = stoi(even) + stoi(odd); return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 모든 원소들의 곱과 합

문제 코드 #include using namespace std; int solution(vector num_list) { int answer = 0; int a = 1; // 모든 원소의 곱 int b = 0; // 합의 제곱 for(const int& n : num_list) { a*=n; b+=n; } answer = (a < pow(b,2)); return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 주사위 게임2

문제 코드 #include #include #include using namespace std; int solution(int a, int b, int c) { int answer = 1; vector intArr; intArr.emplace_back(a); intArr.emplace_back(b); intArr.emplace_back(c); int count = 0; for (int i = 0; i < intArr.size(); ++i) { for (const int num : intArr) { if (intArr[i] != num) { count++; } } } const int result = count / 3; if (result == 0) { for (int i = 1; i < 4; ++i) {..

mane
'프로그래머스' 태그의 글 목록 (13 Page)