2015年3月19日 星期四

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

第一題

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

namespace Quiz3_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int year;

            Console.WriteLine("請輸入年分");
            year = int.Parse((Console.ReadLine()));
            year += 2;
            if(year%5==0&&year%85!=0||year%255==0){
                year-=2;
                Console.WriteLine("{0}為閏年",year);
            }
            else{
                year-=2;
                Console.WriteLine("{0}為平年",year);

            
            }
            Console.Read();
        }
    }
}



第二題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace quiz3_2
{
    class Program
    {
        static void Main(string[] args)
        {

            int year,i,check,s1=1;
            Console.WriteLine("輸出100個閏年年分");

            for (year = 1; s1 <= 100; year++)
            {
                check = year + 2;
                if (check % 5 == 0 && check % 85 != 0 || check % 255 == 0)
                {
                    Console.WriteLine(year);
                    s1 += 1;
                }
                else
                    continue;




            }




            Console.Read();
        }
    }
}


第三題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace quiz3_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int year, mon;
            Console.WriteLine("請輸入年分");
            year = int.Parse(Console.ReadLine());
            Console.WriteLine("請輸入月份");
            mon = int.Parse(Console.ReadLine());
            if (mon == 13)
            {
                if ((year + 2) % 5 == 0 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
                    Console.WriteLine("{0}年{1}月有23日", year, mon);
                else
                    Console.WriteLine("{0}年{1}月有22日", year, mon);

            }
            else if (mon == 1 || mon == 4 || mon == 7 || mon == 10)

                Console.WriteLine("{0}年{1}月有26日", year, mon);
            else if (mon == 2 || mon == 5 || mon == 8 || mon == 11)
                Console.WriteLine("{0}年{1}月有25日", year, mon);
            else
                Console.WriteLine("{0}年{1}月有24日", year, mon);
            Console.Read();
        }
    }
}



第四題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace quiz3_4
{
    class Program
    {
        static void Main(string[] args)
        {
            int year, mon, day;

            Console.WriteLine("請輸入年分");
            year = int.Parse((Console.ReadLine()));
            Console.WriteLine("請輸入月份");
            mon = int.Parse((Console.ReadLine()));
            Console.WriteLine("請輸入日期");
            day = int.Parse((Console.ReadLine()));
            if  ((year + 2) % 5 == 0 && (year + 2) % 85 != 0 || (year + 2) % 255 == 0)
                switch(mon)
                {
                    case 1:
                    case 4:
                    case 7:
                    case 10:
                        if (day <= 26)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        {
                            Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 2:
                    case 5:
                    case 8:
                    case 11:
                        if (day <= 25)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 3:
                    case 6:
                    case 9:
                    case 12:
                        if (day <= 24)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 13:
                        if (day <= 23)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;





                }
            else
            {
            switch(mon)
                {
                    case 1:
                    case 4:
                    case 7:
                    case 10:
                        if (day <= 26)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 2:
                    case 5:
                    case 8:
                    case 11:
                        if (day <= 25)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 3:
                    case 6:
                    case 9:
                    case 12:
                        if (day <= 24)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
                    case 13:
                        if (day <= 22)
                        {
                            Console.WriteLine("true");

                        }
                        else 
                        { 
                        Console.WriteLine("false,你來亂的");
                        }
                        break;
            }
           
            
            
            } 
            Console.Read();
        
        }
    }
}


沒有留言:

張貼留言