1330번: 두 수 비교하기
https://www.acmicpc.net/problem/1330
# 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
if (a > b) {
System.out.println(">");
} else if (a < b) {
System.out.println("<");
} else {
System.out.println("==");
}
}
}
9498번: 시험 성적
https://www.acmicpc.net/problem/9498
# 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long score = sc.nextLong();
if (score >= 90 && score <= 100) {
System.out.println("A");
} else if (score >= 80 && score < 90) {
System.out.println("B");
} else if (score >= 70 && score < 80) {
System.out.println("C");
} else if (score >= 60 && score < 70) {
System.out.println("D");
} else {
System.out.println("F");
}
}
}
14681번: 사분면 고르기
https://www.acmicpc.net/problem/14681
# 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long y = sc.nextLong();
if (x > 0 && y > 0) {
System.out.println("1");
} else if (x < 0 && y > 0) {
System.out.println("2");
} else if (x < 0 && y < 0) {
System.out.println("3");
} else {
System.out.println("4");
}
}
}
2753번: 윤년
https://www.acmicpc.net/problem/2753
# 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long year = sc.nextLong();
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
System.out.println("1");
} else {
System.out.println("0");
}
}
}
2420번: 사파리월드
https://www.acmicpc.net/problem/2420
# 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long m = sc.nextLong();
if (n >= m) {
System.out.println(n - m);
} else {
System.out.println(m - n);
}
}
}
'코딩테스트 > 자바 문제풀이' 카테고리의 다른 글
[새싹: 배열] 백준 10871, 10807, 5597, 2738 (0) | 2024.07.06 |
---|---|
[새싹: 빠른 입출력] 백준 15552 (0) | 2024.07.05 |
[새싹: 반복] 백준 2741, 10872, 10950, 10952, 2739, 2438, 10951 (0) | 2024.07.04 |
[새싹: 입력과 계산] 백준 1000, 1001, 10998, 10869, 1008, 11382 (0) | 2024.07.02 |
[새싹: 출력] 백준 2557, 10699, 7287, 10171, 10172, 25083 (3) | 2024.07.01 |