import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n%2==0){
System.out.println(n + " is even");
}else{
System.out.println(n + " is odd");
}
}
}
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.print(n + " is "+(n % 2 == 0 ? "even" : "odd"));
}
}
홀수와 짝수 표현법
- 삼항연산자를 사용하여 간단하게 풀이하였다. 어렵지 않은 문제일수록 더 효율적인 코드를 고민해봐야겠다.