首页 > 其他 > 详细

输入月份和日期,输出是今年的第多少天,利用switch和case

时间:2016-02-17 12:24:41      阅读:395      评论:0      收藏:0      [点我收藏+]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入月:");
            int m = int.Parse(Console.ReadLine());
            Console.Write("请输入日期:");
            int d = int.Parse(Console.ReadLine());
            int m1=31,m2=28,m3=31,m4=30,m5=31,m6=30,m7=31,m8=31,m9=30,m10=31,m11=30,m12=31;
            switch (m)
            {
                case 1: Console.WriteLine("第" + d + "天");
                    break;
                case 2: Console.WriteLine("第" +(m1+ d) + "天");
                    break;
                case 3: Console.WriteLine("第" + (m1 + m2+d) + "天");
                    break;
                case 4: Console.WriteLine("第" + (m1 + m2+m3+d) + "天");
                    break;
                case 5: Console.WriteLine("第" + (m1 +m2+m3+m4+ d) + "天");
                    break;
                case 6: Console.WriteLine("第" + (m1 +m2+m3+m4+m5+ d) + "天");
                    break;
                case 7: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+ d) + "天");
                    break;
                case 8: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+m7+ d) + "天");
                    break;
                case 9: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+m7+m8+ d) + "天");
                    break;
                case 10: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+m7+m8+m9+ d) + "天");
                    break;
                case 11: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+m7+m8+m9+m10+ d) + "天");
                    break;
                case 12: Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 +m6+m7+m8+m9+m10+m11+ d) + "天");
                    break;
                default:
                    break;

            }
            Console.ReadLine();

 

        }
    }
}

输入月份和日期,输出是今年的第多少天,利用switch和case

原文:http://www.cnblogs.com/jiang2538406936/p/5194633.html

(2)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!