20150910 Enter a date judgment is the first day of the year

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.