标题:为什么我输入2月的时候总是不显示天数,求大神解答!!!
取消只看楼主
a4709
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-3-21
结帖率:0
已结贴  问题点数:20 回复次数:0 
为什么我输入2月的时候总是不显示天数,求大神解答!!!
int  year,month;
            string a="";
            
            Console.WriteLine("请输入年份和月份");
            year = Convert.ToInt32(Console.ReadLine());
            month = Convert.ToInt32(Console.ReadLine());
            if (month <= 12 && month >= 1)            
                switch (month)
                {
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12: a = "31"; break;
                    case 4:
                    case 6:
                    case 9:
                    case 11: a = "30"; break;
                }               
                Console.WriteLine("{0}年{1}月有{2}天", year, month, a);
            if (month >12||month <1)               
                Console.WriteLine("非法数据");
                Console.ReadLine();                 
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
            {
                switch (month)
                {
                    case 2: a = "29"; break;
                }
                        Console.WriteLine("{0}年{1}月有{2}天", year, month, a);
               
               
                                   
                       Console.ReadLine();
            }
2014-03-26 17:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429203-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.281579 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved