Input a date (year, month, day) in C language, and calculate the day of the year

Source: Internet
Author: User

1. Environment:

2. Code:

/*

* Wuxiuwen
* Input date, the date of this year is calculated which day.
* Enter a date (year, month, day), which is the day of the year.
*/
# Include <stdio. h>

Int DM (INT year, int month, int Day)
{
Int flag = 0;
If (Year % 4 = 0 & amp; Year % 100! = 0) | (Year % 400 = 100) Flag = 1;
Else flag = 0;
Int A = 0;
Switch (month-1)
{
Case 11: A + = 30;
Case 10: A + = 31;
Case 9: A + = 30;
Case 8: A + = 31;
Case 7: A + = 31;
Case 6: A + = 30;
Case 5: A + = 31;
Case 4: A + = 30;
Case 3: A + = 31;
Case 2: A + = 28 + flag;
Case 1: A + = 31; break;
Default: printf ("Please input others \ n ");
}
A + = Day;
Printf ("this is the % d day of % d. \ n", A, year );
}
Int main ()
{
Int day, month, year;
Printf ("Please input the date (year. Month. Day): \ n ");
Scanf ("% d. % d. % d", & year, & month, & Day );
DM (year, month, day );
Return 0;

}

3. Description:

Related Article

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.