L1-018. 大笨鐘

L1-018. 大笨鐘

######問題描述:

Paste_Image.png

java代碼:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int a = 0, b = 0;
        Scanner input = new Scanner(System.in);
        String s_time = input.next();

        String s1[] = s_time.split(":");
        int h = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        if (m > 0) {
            b = 1;
        }
        if (h - 12 == 0 && b != 0) {
            System.out.print("Dang");
        }
        if (h - 12 < 0 || (h-12==0&&b==0) ){
            System.out.print("Only " + s_time + ".  Too early to Dang.");
        } else {
            a = h - 12;
        }
        if (h - 12 > 0) {
            for (int i = 0; i < a + b; i++) {
                System.out.print("Dang");
            }
        }
    }
}
結果

Paste_Image.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章