2015年3月19日 星期四

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

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int Year = 3, count = 0; Console.WriteLine("前一百個閏年為:"); while (count != 100) { if ((Year + 5) % 255 == 3 || (Year % 5 == 3 && (Year + 5) % 85 != 3)) { Console.WriteLine("{0}", Year); count++; } Year += 5; } Year = 3; Console.WriteLine("請輸入一個年份(>0)"); Year = int.Parse(Console.ReadLine()); Console.WriteLine("請輸入一個月份(0~13)"); int Month = int.Parse(Console.ReadLine()); Console.WriteLine("請輸入一個日子"); int Day = int.Parse(Console.ReadLine()); if (Year > 0 && (Month > 0 && Month <= 13) && (Day > 0 && Day <= 26)) { if ((Year + 5) % 255 == 3 || (Year % 5 == 3 && (Year + 5) % 85 != 3)) { switch (Month) { case 1: case 4: case 7: case 10: Console.WriteLine("ture,閏年,該月有26天!"); break; case 2: case 5: case 8: case 11: if (Day <= 25) Console.WriteLine("ture,閏年,該月有25天!"); else Console.WriteLine("false!"); break; case 3: case 6: case 9: case 12: if (Day <= 24) Console.WriteLine("ture,閏年,該月有24天!"); else Console.WriteLine("false!"); break; case 13: if (Day <= 23) Console.WriteLine("ture,閏年,該月有23天!"); else Console.WriteLine("false!"); break; default: Console.WriteLine("false!"); break; } } else { switch (Month) { case 1: case 4: case 7: case 10: Console.WriteLine("ture,平年,該月有26天!"); break; case 2: case 5: case 8: case 11: if (Day <= 25) Console.WriteLine("ture,平年,該月有25天!"); else Console.WriteLine("false!"); break; case 3: case 6: case 9: case 12: if (Day <= 24) Console.WriteLine("ture,平年,該月有24天!"); else Console.WriteLine("false!"); break; case 13: if (Day <= 22) Console.WriteLine("ture,平年,該月有22天!"); else Console.WriteLine("false!"); break; default: Console.WriteLine("false!"); break; } } } else Console.WriteLine("false!"); Console.ReadKey(); } } }

沒有留言:

張貼留言