반응형

# 자바 알람 시계 문제

  • 입력된 시간 보다 45분 전 울리는 알람 시계 문제
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();

    m = (m - 45);

    if ( m < 0 ) {
      if ( h == 0 ) {
        h = 24 - 1;
      } else {
        h = h - 1;
      }
      m = 60 + m;
    }

    System.out.println(h + " " + m);

  }
}

 

반응형

'알고리즘 > 프로그래머스, 백준, 구름' 카테고리의 다른 글

백준 2741 N찍기 자바  (0) 2020.10.21
백준 15552 빠른 A+B 자바  (0) 2020.10.21
StringBuffer이용에 따른 수행 시간  (0) 2020.06.13
map 자료구조  (0) 2020.06.04
set 자료구조  (0) 2020.06.04

+ Recent posts