프로그래머스

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

[프로그래머스] Lv.0 n의 배수

문제 코드 #include #include using namespace std; int solution(int num, int n) { int answer = 0; answer = (num % n == 0) ? 1 : 0; return answer; }

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

[프로그래머스] Lv.0 두 수의 연산값 비교하기

문제 코드 #include #include using namespace std; int solution(int a, int b) { int answer = 0; int aa = stoi(to_string(a) + to_string(b)); int bb = 2 * a * b; answer = (aa >= bb) ? aa : bb; return answer; }

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

[프로그래머스] Lv.0 더 크게 합치기

문제 코드 #include #include using namespace std; int solution(int a, int b) { int answer = 0; string str1 = to_string(a)+ to_string(b); string str2 = to_string(b)+ to_string(a); answer = stoi(str1) > stoi(str2) ? stoi(str1) : stoi(str2); return answer; // 다른 사람 문제 풀이 //return max(stoi(to_string(a) + to_string(b)), stoi(to_string(b) + to_string(a))); } int to string -> to_string(int) string to int ->..

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

[프로그래머스] Lv.0 문자열 곱하기

문제 코드 #include #include using namespace std; string solution(string my_string, int k) { string answer = ""; for (int i = 0; i < k; ++i) { answer += my_string; } // 다른 사람 풀이 // while (k--) answer.append(my_string); return answer; }

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

[프로그래머스] Lv.0 문자 리스트를 문자열로 변환하기

문제 코드 #include #include using namespace std; string solution(vector arr) { string answer = ""; for (const string c : arr) { answer += c; } return answer; }

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

[프로그래머스] Lv.0 문자열 섞기

문제 코드 #include #include #include using namespace std; string solution(string str1, string str2) { string answer = ""; for (int i = 0; i < str1.size(); ++i) { answer += str1[i]; answer += str2[i]; } // 다른 사람 풀이 /* for (int i = 0; i < str1.length(); i++) { answer.push_back(str1[i]); answer.push_back(str2[i]); } */ return answer; }

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