1. 10952번: A+B-5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true) {
int a = scanner.nextInt();
int b = scanner.nextInt();
if((a==0) &&(b ==0)) {
break;
}
System.out.println(a+b);
}
}
}
2. 10950번: A+B-3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for(int i=1; i<=t; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
System.out.println(a+b);
}
}
}
3. 11021번: A+B-7
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for(int i=1; i<=t; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
System.out.println("Case #"+(i)+": "+ (a+b));
}
}
}
4. 2884번 알람 시계
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int h = scanner.nextInt();
int m = scanner.nextInt();
int alarm = (h*60)+ m - 45;
if(h == 0 && m < 45) {
h = 23; m= 60+m-45;
}
else if(h == 0 && m == 45 ){
h = 0; m = 0;
}
else {
h = alarm/60;
m = alarm%60;
}
System.out.println(h+" "+ m);
scanner.close();
}
}
'공부기록 > 백준' 카테고리의 다른 글
[백준] 2439번 별찍기 -2 (0) | 2023.02.25 |
---|---|
[백준] 10807번 개수세기, 10871번 X보다 작은 수, 10818번 최소, 최대, 10699번 오늘 날짜 (0) | 2023.02.12 |
[백준] 2525번: 오븐 시계 , 10757번: 큰 수 A+B (0) | 2023.02.01 |
[백준] 25304번 영수증, 10951번 A+B-4, 10870번 피보나치 수 5 (0) | 2023.01.31 |
[백준] 3753번 윤년, 10872번 팩토리얼 (0) | 2023.01.31 |