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

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();

 

        }
    }
}

posted @ 2016-02-17 10:53  什么玩楞啊,我叫旺仔  阅读(662)  评论(0编辑  收藏  举报