CT
[BOJ] 2단계 조건문
kinggora
2023. 1. 23. 17:00
| 1 | 1330 | 두 수 비교하기 |
a, b = map(int, input().split())
if a==b:
print("==")
elif a>b:
print(">")
else:
print("<")
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.print("==");
} else if(a>b){
System.out.print(">");
} else{
System.out.print("<");
}
}
}
| 2 | 9498 | 시험 성적 |
score = int(input())
if 90<=score: print("A")
elif 80<=score: print("B")
elif 70<=score: print("C")
elif 60<=score: print("D")
else: print("F")
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int score = sc.nextInt();
if(90 <= score)
System.out.print("A");
else if(80 <= score)
System.out.print("B");
else if(70 <= score)
System.out.print("C");
else if(60 <= score)
System.out.print("D");
else
System.out.print("F");
}
}
| 3 | 2753 | 윤년 |
year = int(input())
if year%4==0 and (year%100 != 0 or year%400==0):
print(1)
else: print(0)
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
if(year%4==0 && (year%100!=0 || year%400==0)){
System.out.print(1);
} else {
System.out.print(0);
}
}
}
| 4 | 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){
if(y>0){
System.out.print(1);
} else{
System.out.print(4);
}
} else{
if(y>0){
System.out.print(2);
} else{
System.out.print(3);
}
}
}
}
| 5 | 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();
int mh = h;
int md = m - 45;
if(md < 0){
md = 60 + md;
mh -= 1;
if(mh < 0){
mh = 24 + mh;
}
}
System.out.print(mh + " " + md);
}
}
| 6 | 2525 | 오븐 시계 |
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();
int c = sc.nextInt();
int hd = c/60;
int md = c%60;
m += md;
h += hd;
if(m >= 60){
h += 1;
m -= 60;
}
if(h >= 24){
h -= 24;
}
System.out.print(h + " " + m);
}
}
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();
int c = sc.nextInt();
int min = h * 60 + m;
min += c;
int hh = min / 60 % 24;
int mm = min % 60;
System.out.print(hh+ " " + mm);
}
}
| 7 | 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();
if(a == b && a == c){
System.out.print(10000 + a * 1000);
} else if(a == b){
System.out.print(1000 + a * 100);
} else if(a == c){
System.out.print(1000 + a * 100);
} else if(b == c){
System.out.print(1000 + b * 100);
} else{
int max = Math.max(Math.max(a,b),c);
System.out.print(max * 100);
}
}
}
*Math.max(a,b)