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;
            }
        }
    }
}

截图

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM