1330번 두 수 비교하기
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if (a > b) {
System.out.println(">");
}
else if(a < b) {
System.out.println("<");
}
else {
System.out.println("==");
}
sc.close();
}
}
9498번 시험 성적
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int score = sc.nextInt();
if(score >= 90) {
System.out.println("A");
} else if(score >= 80) {
System.out.println("B");
} else if(score >= 70) {
System.out.println("C");
} else if(score >= 60) {
System.out.println("D");
} else {
System.out.println("F");
}
sc.close();
}
}
2753번 윤년
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int y = sc.nextInt();
if(y % 4 == 0) {
if(y % 400 == 0) {
System.out.println("1");
} else if (y % 100 == 0) {
System.out.println("0");
} else {
System.out.println("1");
}
} else {
System.out.println("0");
}
sc.close();
}
}
14681번 사분면 고르기
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
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");
}
sc.close();
}
}
2884번 알람 시계
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt();
int m = sc.nextInt();
if(m < 45) {
m += 15;
if(h == 0) {
h = 23;
} else {
h -= 1;
}
} else {
m -= 45;
}
System.out.println(h + " " + m);
sc.close();
}
}
2525번 오븐 시계
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int n = sc.nextInt();
int k = 60 * a + b;
k += n;
int h = (k / 60) % 24;
int m = k % 60;
System.out.println(h + " " + m);
}
}
2480번 주사위 세개
문제
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int n = 0;
if(a == b && b == c) {
n = 10000 + a * 1000;
} else if(a == b || b == c) {
n = 1000 + b * 100;
} else if(c == a) {
n = 1000 + a * 100;
} else {
n = Math.max(Math.max(a, b), c) * 100;
}
System.out.println(n);
sc.close();
}
}