본문 바로가기
Code/baekjoon [ 단계별 ]

백준 단계별 문제 <if문 >

by jaeaemin 2022. 1. 20.

[14681번]  : 사분면 고르기 자바

 

import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
     
        sc.close();
        
        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);
        } 
    }
}

 

 

 

 

[2884번] : 알람 시계

 

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int hour = sc.nextInt();
        int minute = sc.nextInt();
        sc.close();
        
        if(minute >= 45){
            minute=minute-45;
        }
        else{
            minute=minute+(60-45);
            if(hour==0){
                hour = 23;
            }
            else{
                hour--;
            }
        }
        System.out.print(hour+" "+minute);
    }
}

 

 

 

반응형