| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2823 人关注过本帖
标题:新手初学C#求大神解答,输出日历的方法要怎样写,我这样写该怎么改
取消只看楼主 加入收藏
勿忘心安、
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-7-27
结帖率:100%
收藏
已结贴  问题点数:5 回复次数:0 
新手初学C#求大神解答,输出日历的方法要怎样写,我这样写该怎么改
     public void  Calendar()
        {
            switch (_month)
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:

                    for (int i = 1; i <= 31; i++)
                    {
                        Console.Write(i + " ");
                        if (i % 7 == 0)
                        {
                            Console.WriteLine();
                        }
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    for (int i = 1; i <= 30; i++)
                    {
                        Console.Write(i + " ");
                        if (i % 7 == 0)
                        {
                            Console.WriteLine();
                        }
                    }
                    break;
                case 2:
                    if (_year % 4 == 0 && _year % 100 != 0 || _year % 400 == 0)
                    {
                        for (int i = 1; i <= 29; i++)
                        {
                            Console.Write(i + " ");
                            if (i % 7 == 0)
                            {
                                Console.WriteLine();
                            }
                        }
                    }
                    else
                    {
                        for (int i = 1; i <= 28; i++)
                        {
                            Console.Write(i + " ");
                            if (i % 7 == 0)
                            {
                                Console.WriteLine();
                            }
                        }
                    }
                    break;
            }
        }
搜索更多相关主题的帖子: public 日历 
2016-07-27 20:34
快速回复:新手初学C#求大神解答,输出日历的方法要怎样写,我这样写该怎么改
数据加载中...
 
   



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

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