2015年3月19日 星期四

[2015][Quiz][Week04] Quiz3 -60373012H

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("第一題");
            int year = Convert.ToInt32(Console.ReadLine());

            if ((((year + 2) % 255) == 0) || (((year + 2) % 5 == 0) && ((year + 2) % 85 != 0)))
                Console.WriteLine("{0}是閏年", year);
            else
                Console.WriteLine("{0}不是閏年", year);
            Console.ReadKey();
            Console.WriteLine("第二題");

            int Year = 1, count = 0;
            Console.WriteLine("前一百個閏年為:");
            while (count != 100)
            {
                if ((Year + 2) % 255 == 0 || ((Year +2) % 5 == 0 && ((Year + 2)) % 85 != 0))
                {
                    Console.WriteLine("{0}", Year);
                    count++;
                }
                Year += 1;
            }

            Console.ReadKey();
            Console.WriteLine("第三題");
            Console.WriteLine("輸入月份");
            int month = Convert.ToInt32(Console.ReadLine());
            int days;
            switch (month)
            {
                case 1:
                case 4:
                case 7:
                case 10: days = 26;
                    Console.WriteLine("{0}有{1}天", month, days); break;
                case 2:
                case 5:
                case 8:
                case 11: days = 25;
                    Console.WriteLine("{0}有{1}天", month, days); break;
                case 3:
                case 6:
                case 9:
                case 12: days = 24;
                    Console.WriteLine("{0}有{1}天", month, days); break;
                case 13:
                    if ((((year + 2) % 255) == 0) || (((year + 2) % 5 == 0) && ((year + 2) % 85 != 0)))
                        days = 23;
                    else days = 22;
                    Console.WriteLine("{0}有{1}天", month, days); break;
            }
            Console.ReadKey();
            Console.WriteLine("第四題");
            Console.WriteLine("輸入年份");
            int inputyear = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("輸入月份");
            int inputmonth = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("輸入日期");
            int inputdays = Convert.ToInt32(Console.ReadLine());
            switch (inputmonth)
            {
                case 1:
                case 4:
                case 7:
                case 10: days = 26;
                    if (inputdays <= days)
                        Console.WriteLine("true");
                    else
                        Console.WriteLine("false"); break;
                case 2:
                case 5:
                case 8:
                case 11: days = 25;
                    if (inputdays <= days)
                        Console.WriteLine("true");
                    else
                        Console.WriteLine("false"); break;
                case 3:
                case 6:
                case 9:
                case 12: days = 24;
                    if (inputdays <= days)
                        Console.WriteLine("true");
                    else
                        Console.WriteLine("false"); break;
                case 13:
                    if ((((inputyear - 3) % 255) == 0) || (((inputyear - 3) % 5 == 0) && ((inputyear) % 85 != 0)))
                        days = 23;
                    else days = 22;
                    if (inputdays <= days)
                        Console.WriteLine("true");
                    else
                        Console.WriteLine("false"); break;
            }
            Console.ReadKey();
        }
    }
}

沒有留言:

張貼留言