| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 411 人关注过本帖
标题:为什么我输入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
快速回复:为什么我输入2月的时候总是不显示天数,求大神解答!!!
数据加载中...
 
   



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

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