프로그래머스(코딩테스트 연습)
프로그래머스 두 수의 연산값 비교하기 C++
Dev_Jen
2023. 9. 23. 02:36
반응형
#include <string>
#include <vector>
using namespace std;
int solution(int a, int b) {
int answer = 0;
string a1 = to_string(a);
string b1 = to_string(b);
string a_b = a1 + b1;
if(stoi(a_b) <= 2*a*b ){
answer = 2*a*b;
}
else{
answer = stoi(a_b);
}
return answer;
}
처음 문제를 읽었을때 제대로 이해가 안됐었다..ㅋㅋㅋ 그래서 문제를 제대로 이해하고 푸는게 중요하다. 문제 출제자의 의도를 파악하고 문제를 푸는것!
반응형