C# 计算天数
using System;
using System.Collections.Generic;
using System.Text;
namespace Days
{
enum month { Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };
class Program
{
static void Main(string[] args)
{
month m;
int n = 0;
Console.WriteLine(" 计算天数\n");
Console.Write("输入月份(1~12):");
m = (month)(Convert.ToInt16(Console.ReadLine()));
switch (m)
{
case month.Jan:
case month.Mar:
case month.May:
case month.Jul:
case month.Aug:
case month.Oct:
case month.Dec:
n = 31;
break;
case month.Feb:
case month.Jun:
case month.Sep:
case month.Nov:
n = 30;
break;
default:
Console.WriteLine("输入的数据有误,月份只能为1~12.");
break;
} Console.WriteLine("{0}月共有{1}天", m, n);
Console.ReadLine();
}
}
} |
|