Question one hundred and fifteen: Day

Source: Internet
Author: User

[Plain] Description
 
Given a date, the output date is the day of the year.
 
Input
 
There are multiple groups of input data, each group occupies a row, the data format is composed of YYYY-MM-DD, see sample input, In addition, you can ensure that all input data is valid.
 
Output
 
For each group of input data, a row is output, indicating that the date is the day of the year.
 
Sample Input
 
 
2000-01-01
 
Sample Output
 
 
1

Description

Given a date, the output date is the day of the year.

Input

There are multiple groups of input data, each group occupies a row, the data format is composed of YYYY-MM-DD, see sample input, In addition, you can ensure that all input data is valid.

Output

For each group of input data, a row is output, indicating that the date is the day of the year.

Sample Input


2000-01-01

Sample Output


1
 


[Plain] # include <stdio. h>
 
Int cheakyear (int year );
 
Int main ()
{
Int I;
Int flag;
Int year;
Int month;
Int day;
Int sum;
Int array [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 };

While (scanf ("% d-% d", & year, & month, & day )! = EOF)
{
Sum = 0;
Flag = cheakyear (year );
 
For (I = 0; I <month; I ++)
{
Sum + = array [I];
}
 
Sum + = day;
 
If (flag & month> 2)
{
Sum ++;
}
 
Printf ("% d \ n", sum );
 
}
Return 0;
}
 
Int cheakyear (int year)
{
Int flag;

Flag = 0;
 
If (year % 400 = 0) | (year % 100! = 0 & year % 4 = 0 ))
{
Flag = 1;
}
 
Return flag;
}

# Include <stdio. h>

Int cheakyear (int year );

Int main ()
{
Int I;
Int flag;
Int year;
Int month;
Int day;
Int sum;
Int array [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 };

While (scanf ("% d-% d", & year, & month, & day )! = EOF)
{
Sum = 0;
Flag = cheakyear (year );

For (I = 0; I <month; I ++)
{
Sum + = array [I];
}

Sum + = day;

If (flag & month> 2)
{
Sum ++;
}

Printf ("% d \ n", sum );

}
Return 0;
}

Int cheakyear (int year)
{
Int flag;
 
Flag = 0;

If (year % 400 = 0) | (year % 100! = 0 & year % 4 = 0 ))
{
Flag = 1;
}

Return flag;
}
 

 



 

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.