코딩테스트

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

[프로그래머스/C++] Lv.flag 에 따라 다른 값 반환하기

문제 코드 #include #include using namespace std; int solution(int a, int b, bool flag) { return (flag ? a + b : a - b); }

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

[프로그래머스/C++] Lv.0 조건 문자열

문제 코드 #include int solution(std::string ineq, std::string eq, int n, int m) { int answer = 0; char c[2]; strcpy(c, (ineq + eq).c_str()); if (strcmp(c, ">=") == 0) { answer = (n >= m); } else if (strcmp(c, "!") == 0) { answer = (n > m); } else { answer = (n < m); } return answer; } // 다른 사람 풀이 //int solution(string ineq, string eq, int n, int m) { // string oper = ineq + eq; // if (oper == "=") /..

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

[프로그래머스/C++] Lv.0 홀짝에 따라 다른 값 반환하기

문제 코드 #include #include using namespace std; int solution(int n) { int answer = 0; for (int i = 1; i

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

[프로그래머스/C++] Lv.0 공배수

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

mane
'코딩테스트' 태그의 글 목록 (15 Page)