본문 바로가기

알고리즘/Java

(JAVA) 백준 알고리즘 2단계 2884번 : 알람 시계

아 벌써부터 이러면 안되는데 너무 애먹었다..

 

실수 : else if(b<45) 조건을 쓰지않고 else로 처리함. = 실패 

 

 

소스

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
     
    if(b>=45) {
        System.out.println(a+" "+(b-45));
    }else if(b<45){
         if(a-1<0){
             a=24;
         }
         System.out.println((a-1)+" "+(b+15));
         }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter