zoukankan      html  css  js  c++  java
  • C#语言,从键盘输入一个年份和一个月份,判断该月是多少天!

    Console.WriteLine("请输入一个年份:");
    int year = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("请输入一个月份:");
    int month = Convert.ToInt32(Console.ReadLine());
    switch (month)
    {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: Console.WriteLine("该月有31天!"); break;
    case 4:
    case 6:
    case 9:
    case 11: Console.WriteLine("该月有30天!"); break;
    case 2:
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
    Console.WriteLine("今年是闰年!有29天!");
    }
    else
    {
    Console.WriteLine("今年是平年!有28天!");
    }
    break;
    default: Console.WriteLine("您输入的月份错误!"); break;
    }

  • 相关阅读:
    菜根谭#308
    菜根谭#307
    菜根谭#306
    菜根谭#305
    菜根谭#304
    菜根谭#303
    菜根谭#302
    菜根谭#301
    菜根谭#300
    菜根谭#299
  • 原文地址:https://www.cnblogs.com/Jasxu/p/3021937.html
Copyright © 2011-2022 走看看