C# 编写一个控制台应用程序,可根据输入的月份判断所在季节。

using System;
using System.Collections.Generic;
using System.Text;

namespace Test_1
{
    class test_1_2
    {
        static void Main(String[] args)
        {
            int i;
            while (true)
            {
                Console.WriteLine("请输入月份号:");
                i = int.Parse(Console.ReadLine());
                switch (i)
                {
                    case 3:
                    case 4:
                    case 5:
                        Console.WriteLine("春季");
                        break;
                    case 6:
                    case 7:
                    case 8:
                        Console.WriteLine("夏季");
                        break;
                    case 9:
                    case 10:
                    case 11:
                        Console.WriteLine("秋季");
                        break;
                    case 12:
                    case 1:
                    case 2:
                        Console.WriteLine("冬季");
                        break;
                    default:Console.WriteLine("退出");
                        break;
                }
                if (i >= 13||i<=0) break;
            }
        }
    }
}

截图

原文地址:https://www.cnblogs.com/dty602511/p/15416367.html