黑马程序员技术交流社区

标题: C# 计算天数 [打印本页]

作者: 李建龙    时间: 2013-6-10 21:08
标题: C# 计算天数
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();
        }
    }
}
作者: ljh4282158    时间: 2013-6-10 21:16
这个你想证明啥?




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2