A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 李建龙 中级黑马   /  2013-6-10 21:08  /  1901 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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();
        }
    }
}

1 个回复

倒序浏览
这个你想证明啥?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马