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