hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #큰 시계 #266

Open hwangnk1004 opened 4 years ago

hwangnk1004 commented 4 years ago

import java.util.Scanner;

public class Main { public static void main(String args[]) {

    Scanner scanner = new Scanner(System.in);

    int[] hour = new int[24];
    int[] minute = new int[60];

    String h = scanner.nextLine();
    String[] kk = h.split(":");

    hour[Integer.valueOf(kk[0])]++;
    minute[Integer.valueOf(kk[1])]++;

    int x = 0;

    for(int i=0; i<hour.length; i++) {

        if (hour[i] >=1) {
            x=i;
        }
    }

    if (x<=12) {
        x +=12;
    } else {
        x-=12;
    }

    for(int i=1; i<minute.length; i++) {
        if (minute[i] >=1) {
            System.out.println(0);
            return;
        }

    }

    System.out.println(x);
}

}

hwangnk1004 commented 4 years ago