using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
try
{
string m = Console.ReadLine();
string[] str = m.Split('/');
int day = int.Parse(str[2]) % 30;
if (day == 0)
{
day = 30;
}
int month = (int.Parse(str[1]) + int.Parse(str[2]) / 30) % 12;
if (month == 0)
{
month = 12;
}
int year = int.Parse(str[0]) + (int.Parse(str[1]) + int.Parse(str[2]) / 30) / 12;
int daynumber = 0;
if (Isleap(year))
{
Console.WriteLine("闰年");
}
else
{
Console.WriteLine("不是闰年");
}
if (Nummonth(month, Isleap(year)) > 30)
{
Console.WriteLine("大月");
}
else
{
Console.WriteLine("小月");
}
for (int i = 1; i < month; i++)
{
daynumber += Nummonth(i, Isleap(year));
}
daynumber += day;
Console.WriteLine("一年的第" + daynumber.ToString()+"天");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.ReadKey();
}
/// 判断闰年
/// </summary>
/// <param name="year">年份</param>
/// <returns>是否闰年</returns>
static bool Isleap(int year)
{
return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
}
/// <summary>
/// 计算当月的天数
/// </summary>
/// <param name="month">月份</param>
/// <param name="b">是否闰年</param>
/// <returns>当月的天数</returns>
static int Nummonth(int month, bool b)
{
int num;
if (month == 2 && b)
{
num = 29;
}
else
{
if (month == 2 && !b)
{
num = 28;
}
else
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
num = 31;
}
else
{
num = 30;
}
}
}
return num;
}
}
}
[
本帖最后由 jedypjd 于 2009-8-28 19:07 编辑 ]