BOOL isOK = false;//used to record the correct date
BOOL Isrun = false;//used to determine whether a leap year
Console.Write ("Input year:");
int year = Int. Parse (Console.ReadLine ());
Console.Write ("Input month:");
int month = Int. Parse (Console.ReadLine ());
Console.Write ("Input Date:");
int day = Int. Parse (Console.ReadLine ());
BOOL isOK = false;//used to record the correct date
BOOL Isrun = false;//used to determine whether a leap year
If (year >= 1759 && year < 9999)
{
if (month >= 1 && month <=)
{
if (MO) (for the year), "{") ' (*) * * Nth = = 2)
{
if (year% 400 = = 0 | | (year% 4 = = 0 && Year% 100! = 0))
{
if (Day >= 1 && day <=)
{
isOK = true;
Isrun = true;
}
Else
{
Console.WriteLine ("should be within 29 days range");
}
}
Else
{
if (Day >= 1 && day <=)
{
isOK = true;
}
Else
{
Console.WriteLine ("should be within 28 days range");
}
}
}
if (month = = 1 | | month = = 3 | | month = = 5 | | month = = 7 | | month = = 8 | | month = = Ten | | month = =)
{
if (Day >= 1 && day <=)
{
isOK = true;
}
Else
{
Console.WriteLine ("Date should be within 31 days");
}
}
if (month = = 4 | | month = = 6 | | month = = 9 | | month = = 11)
{
if (Day >= 1 && Day <= 30)
{
isOK = true;
}
Else
{
Console.WriteLine ("Date shall be within 30 days");
}
}
}
Else
{
Console.WriteLine ("Incorrect Month");
}
}
Else
{
Console.WriteLine ("Incorrect Year");
}
int sumday = 0;//number of days
if (isOK)//date correct, count days
{
if (Isrun)//is a leap year
{
if (month = = 1)
{
Sumday = day;
}
if (month = = 2)
{
Sumday = + Day;
}
if (month = = 3)
{
Sumday = + + day;
}
if (month = = 4)
{
Sumday = + + + day;
}
if (month = = 5)
{
Sumday = + + + + + day;
}
if (month = = 6)
{
Sumday = + + + + + + + day;
}
if (month = = 7)
{
Sumday = + + + + + + + + day;
}
if (month = = 8)
{
Sumday = + + + + + + + + + day;
}
if (month = = 9)
{
Sumday = + + + + + + + + + + + + day;
}
if (month = = 10)
{
Sumday = + + + + + + + + + + day;
}
if (month = = 11)
{
Sumday = + + + + + + + + + + day;
}
if (month = = 12)
{
Sumday = + + + + + + + + + + + + + +
}
}
Else
{
if (month = = 1)
{
Sumday = day;
}
if (month = = 2)
{
Sumday = + Day;
}
if (month = = 3)
{
Sumday = + + day;
}
if (month = = 4)
{
Sumday = + + + day;
}
if (month = = 5)
{
Sumday = + + + + + day;
}
if (month = = 6)
{
Sumday = + + + + + + + day;
}
if (month = = 7)
{
Sumday = + + + + + + + + day;
}
if (month = = 8)
{
Sumday = + + + + + + + + day;
}
if (month = = 9)
{
Sumday = + + + + + + + + + + + day;
}
if (month = = 10)
{
Sumday = + + + + + + + + + + + + day;
}
if (month = = 11)
{
Sumday = + + + + + + + + + + + + + + +
}
if (month = = 12)
{
Sumday = + + + + + + + + + + + + + +
}
}
Console.WriteLine ("{0} days", Sumday);
}
Else
{
Console.WriteLine ("The date is not correct, can't be counted!") ");
}
Console.ReadLine ();
}
20150910 Enter a date judgment is the first day of the year