[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;
}