728x90
반응형
SMALL
#include <string>
#include <vector>
using namespace std;
int solution(int number, int n, int m) {
int val1 = number%n > 0 ? 0:1;
int val2 = number%m > 0 ? 0:1;
if(val1*val2)
return 1;
else
return 0;
}
#include <string>
#include <vector>
using namespace std;
int solution(int number, int n, int m) {
return (number%n==0) && (number%m==0)? 1: 0;
}
* &&연산을 활용해서 한줄로 작성가능
728x90
반응형
LIST
'C++' 카테고리의 다른 글
| [프로그래머스] flag에 따라 다른 값 반환하기 (0) | 2025.08.28 |
|---|---|
| [프로그래머스] 조건 문자열 (1) | 2025.08.28 |
| [프로그래머스] n의 배수 (0) | 2025.08.27 |
| [프로그래머스] 두 수의 연산값 비교하기 (0) | 2025.08.27 |
| [프로그래머스] 더 크게 합치기 (0) | 2025.08.27 |
댓글