✅ 문제
✅ 사전 구상
- 자연수 n 이 주어지면 n을 2로 나눠서 나머지가 0이면 짝수 출력! 아니면 홀수 출력
package lv_0;
import java.util.Scanner;
public class oddeven {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int result = n % 2;
if (result == 0) {
System.out.printf("%d is even", n);
} else {
System.out.printf("%d is odd", n);
}
}
}
✅ 결과
https://github.com/Beast-IT/Programmers.git
GitHub - Beast-IT/Programmers: 코딩테스트 연습!
코딩테스트 연습! Contribute to Beast-IT/Programmers development by creating an account on GitHub.
github.com
Github에 들어가시면 원본 코드 보실 수 있습니다.
'IT > 코딩연습!' 카테고리의 다른 글
[프로그래머스 Lv.0] ✏️문자 리스트를 문자열로 변환하기 (0) | 2023.06.13 |
---|---|
[프로그래머스 Lv.0]✏️ n의 배수 (0) | 2023.06.13 |
[프로그래머스 Lv.0] ✏️ 문자열 섞기 (0) | 2023.06.13 |
[프로그래머스 Lv.0] ✏️ 문자열 겹쳐쓰기 (0) | 2023.06.10 |
[프로그래머스 Lv.0] ✏️ 대소문자 바꿔서 출력하기 (0) | 2023.06.10 |