티스토리 뷰

 문제 


 풀이 - Java 11 

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();

        if ((H >= 0 && H <= 23) && (M >= 0 && M <= 59)) {
            if (M < 45) {
                if (H!=0){
                    System.out.println((H-1)+" "+(M+15));
                }else {
                    System.out.println(23+" "+(M+15));
                }
            } else if (M >= 45) {
                System.out.println(H+" "+(M-45));
            }
        }
    }
}

 풀이 - C++ 

#include <stdio.h>

int main()
{
  int H, M;
  
  scanf("%d %d", &H, &M);
  
  if ((H >= 0 && H <= 23) && (M >= 0 && M <= 59)) {
      if (M < 45) {
          if (H!=0){
              printf("%d %d",(H-1), (M+15));
          }else {
              printf("%d %d", 23, (M+15));
          }
      } else if (M >= 45) {
          printf("%d %d", H, (M-45));
      }
  }
}

 알아야하는 개념