내 답안
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.print(n + " is even");
}else{
System.out.print(n + " is odd");
}
}
}
Java
복사
다른 사람 풀이법
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"));
}
}
Java
복사