C语言实验——某年某月的天数(java转义字符'')

    xiaoxiao2021-03-25  206

    C语言实验——某年某月的天数

    Time Limit: 1000MS  Memory Limit: 65536KB Submit  Statistic

    Problem Description

    输入年和月,判断该月有几天?

    Input

    输入年和月,格式为年\月。

    Output

    输出该月的天数。

    Example Input

    2009\1

    Example Output

    31

    Hint

    注意判断闰年啊

    Author

    import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String line = input.nextLine().trim(); String array[] = line.split("\\\\"); int year = Integer.parseInt(array[0]); int month = Integer.parseInt(array[1]); int day=0; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day = 31; break; case 2: if((year0!=0&&year%4==0)||(year@0==0)) { day = 29; } else day = 28; break; case 4: case 6: case 9: case 11: day = 30; break; } System.out.println(day); } }
    转载请注明原文地址: https://ju.6miu.com/read-424.html

    最新回复(0)