using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1.輸入一個星球紀元年分,將會判斷其為閏年或平年");
Console.WriteLine("2.列出星球紀元前100個閏年的年份");
Console.WriteLine("3.輸入一個年份及月份,印出該月的天數");
Console.WriteLine("4.輸入年、月、日,判斷該日是否合法");
Console.WriteLine("請輸入1~4進行選擇");
int select;
select = int.Parse(Console.ReadLine());
int y, year, month, day;
switch(select)
{
case 1:
{
Console.WriteLine("請輸入一星球紀元年份");
y=int.Parse(Console.ReadLine());
year = y +2 ;
if(year%255==0)
Console.WriteLine("星球紀元{0}年為閏年",y);
else if(year%5==0&&year%85!=0)
Console.WriteLine("星球紀元{0}年為閏年",y);
else
Console.WriteLine("星球紀元{0}年為平年",y);
Console.Read();
}
break;
case 2:
{
int a=0;
for(int i=3;a<100;i+=5)
{
year=i+2;
if (year % 255 == 0)
{
Console.WriteLine("{0}", i);
a++;
}
else if (year % 5 == 0 && year % 85 != 0)
{
Console.WriteLine("{0}", i);
a++;
}
}
Console.WriteLine("以上為星球紀元前{0}個閏年", a);
Console.Read();
}
break;
case 3:
{
Console.WriteLine("請輸入一星球紀元年份");
y = int.Parse(Console.ReadLine());
Console.WriteLine("請輸入一星球紀元月份(1~13)");
month = int.Parse(Console.ReadLine());
switch(month)
{
case 1:
case 4:
case 7:
case 10:
Console.WriteLine("星球紀元{0}年{1}月為大月,有26天", y, month);
break;
case 2:
case 5:
case 8:
case 11:
Console.WriteLine("星球紀元{0}年{1}月為中月,有25天", y, month);
break;
case 3:
case 6:
case 9:
case 12:
Console.WriteLine("星球紀元{0}年{1}月為小月,有24天", y, month);
break;
case 13:
{
year=y+2;
if (year % 255 == 0)
Console.WriteLine("星球紀元{0}年為閏年,{1}月有23天", y, month);
else if (year % 5 == 0 && year % 85 != 0)
Console.WriteLine("星球紀元{0}年為閏年,{1}月有23天", y, month);
else
Console.WriteLine("星球紀元{0}年為閏年,{1}月有22天", y, month);
}
break;
default:
Console.WriteLine("輸入錯誤!!");
break;
}
Console.Read();
}
break;
case 4:
{
Console.WriteLine("請輸入一星球紀元年份");
y = int.Parse(Console.ReadLine());
Console.WriteLine("請輸入一星球紀元月份(1~13)");
month = int.Parse(Console.ReadLine());
Console.WriteLine("請輸入一星球紀元日期");
day = int.Parse(Console.ReadLine());
if (month == 1 || month == 4 || month == 7 || month == 10 && day <= 26)
Console.WriteLine("true");
else if (month == 2 || month == 5 || month == 8 || month == 11 && day <= 25)
Console.WriteLine("true");
else if (month == 3 || month == 6 || month == 9 || month == 12 && day <= 24)
Console.WriteLine("true");
else if (month == 13)
{
year = y+2;
if (year % 255 == 0 && day <= 23)
Console.WriteLine("true");
else if (year % 5 == 0 && year % 85 != 0 && day <= 23)
Console.WriteLine("true");
else if (day <= 22)
Console.WriteLine("true");
else
Console.WriteLine("false");
}
else
Console.WriteLine("false");
Console.Read();
}
break;
default:
Console.WriteLine("請輸入1~4");
Console.Read();
break;
Console.Read();
}
}
}
}
2015年3月19日 星期四
[2015][Quiz][Week04] Quiz3 - 40173022H
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言