美文网首页
2018-11-07作业2

2018-11-07作业2

作者: 追魂_409e | 来源:发表于2018-11-07 15:05 被阅读0次

class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("请输入一个年份");

            int year = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("请输入一个月份");

            int month = Convert.ToInt32(Console.ReadLine());

            if (month >= 1 && month <= 12)

            {

                int day = 0;//存储天数

                switch (month)

                {

                    case 1:

                    case 3:

                    case 5:

                    case 7:

                    case 8:

                    case 10:

                    case 12: day = 31;

                        break;

                    case 2:

                        if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))

                        {

                            day = 29;

                        }

                        else

                        {

                            day = 28;

                        }

                        break;

                    default: day = 30;

                        break;

                }//swich

                Console.WriteLine("{0}年{1}月有{2}天", year, month, day);

            }//if

            else

            {

                Console.WriteLine("月份必须在1~12月之间,程序退出!!!");

            }

            Console.ReadKey();

相关文章

  • 2018-11-07本周6组作业汇总

    2018-11-07本周6组作业汇总如下: 姓名:冯少杰 编号:10689作业题目:我的女儿 作业链接:https...

  • 2018-11-07作业2

    Console.WriteLine("请输入一个年份"); int year = Convert.ToInt32(...

  • 2018-11-07作业2

    class Program { static void Main(string[] args) ...

  • 2018-11-07作业2

    int year = Convert.ToInt32(Console.ReadLine());Console.Wr...

  • 第十七篇

    2018-11-07 星期三 天气晴 今天回来的早。回到家,孩子吃完饭刚去写作业。 孩子写作业,我给他出题,做...

  • 《能断金刚》第一期作业20181107

    《能断金刚》第一期学习感悟 成丽萍 作业已提交2018-11-07 1、我们真正的成功是如何获得的?我们通过帮助他...

  • 2018-11-07

    六项精进 2018-11-07 姓名:彭雪 公司:广汉油脂 354期学员 379期志工 【日精进打卡第2...

  • 2018-11-07

    layout: "post"title: "test"date: "2018-11-07 18:11"next: ...

  • 2018-11-07作业

    立冬,冬天的开始,要吃饺子。 暖暖的饺子驱散了冬日的刺骨的寒意。路上的行人都将所有的秋装收了起来,换上了臃肿的冬装...

  • 2018-11-07作业

    Console.WriteLine("请输入名字");string name = Console.ReadLine...

网友评论

      本文标题:2018-11-07作业2

      本文链接:https://www.haomeiwen.com/subject/krdvxqtx.html