2015年3月19日 星期四

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

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

namespace quiz3
{
    class Program
    {
        static void Main(string[] args)
        {
            int year;
            string n;
            Console.Write("請輸入你要查詢的年份\n");
            n = Console.ReadLine();
            year = int.Parse(n);
            if (year % 5 == 3 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
            {
                Console.Write("這一年是閏年\n");
            }
            else 
            {
                Console.Write("這一年是平年\n");
            }
            Console.ReadKey();
        }
    }
}

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

namespace quiz3_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int year = 0;
            int count = 0;
            while (count <= 100)
            {
                year++;
                if (year % 5 == 3 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
                {
                    Console.Write("{0}\n",year);
                    count++;
                }
            }
            Console.ReadKey();
        }
    }
}

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

namespace quiz3_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int year,month;
            string n,m;
            Console.Write("請輸入你要查詢的年份及月份\n");
            n = Console.ReadLine();
            m = Console.ReadLine();
            year = int.Parse(n);
            month = int.Parse(m);
            switch(month)
                {
                    case 1:
                        Console.Write("這個月是26天\n");
                        break;
                    case 4:
                        Console.Write("這個月是26天\n");
                        break;
                    case 7:
                        Console.Write("這個月是26天\n");
                        break;
                    case 10:
                        Console.Write("這個月是26天\n");
                        break;
                    case 2:
                        Console.Write("這個月是25天\n");
                        break;
                    case 5:
                        Console.Write("這個月是25天\n");
                        break;
                    case 8:
                        Console.Write("這個月是25天\n");
                        break;
                    case 11:
                        Console.Write("這個月是25天\n");
                        break;
                    case 3:
                        Console.Write("這個月是24天\n");
                        break;
                    case 6:
                        Console.Write("這個月是24天\n");
                        break;
                    case 9:
                        Console.Write("這個月是24天\n");
                        break;
                    case 12:
                        Console.Write("這個月是24天\n");
                        break;
            }
            if (year % 5 == 3 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
            {
                switch (month)
                {
                    case 13:
                        Console.Write("這個月是23天\n");
                        break;
                }
            }
            else
            {
                switch (month)
                {
                    case 13:
                        Console.Write("這個月是22天\n");
                        break;
                }
            }
            Console.ReadKey();
        }
    }
}

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

namespace quiz3_4
{
    class Program
    {
        static void Main(string[] args)
        {
            int year, month,day;
            string n, m, d;
            Console.Write("請輸入你要查詢的年份及月份及日期\n");
            n = Console.ReadLine();
            m = Console.ReadLine();
            d = Console.ReadLine();
            year = int.Parse(n);
            month = int.Parse(m);
            day = int.Parse(d);
            if (month == 1 || month == 4 || month == 7 || month == 10)
            {
                if (day > 26)
                {
                    Console.Write("false\n");
                }
            }
            else if (month == 2 || month == 5 || month == 8 || month == 11)
            {
                if (day > 25)
                {
                    Console.Write("false\n");
                }
            }
            else if (month == 3 || month == 6 || month == 9 || month == 12)
            {
                if (day > 24)
                {
                    Console.Write("false\n");
                }
            }
            else if (month == 13)
            {
                if (year % 5 == 3 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
                {
                    if (day > 23)
                    {
                        Console.Write("false\n");
                    }
                    else
                    {
                        Console.Write("true\n");
                    }
                }
                else
                {
                    if (day > 22)
                    {
                        Console.Write("false\n");
                    }
                    else
                    {
                        Console.Write("true\n");
                    }
                }
            }
            else
            {
                Console.Write("true\n");
            }
            Console.ReadKey();
        }
    }
}

2 則留言:

  1. 如果不是在同一字串顯示中需要再換行
    使用Console.WriteLine即可省略掉用Console.Write還需要\n的舉動

    回覆刪除
  2. 還有 關愛一下 你的標題格式錯了喔

    回覆刪除