[Plain] Description
The time spent in college is really precious, and you have to hurry up with AC ^ _ ^. Do you know that today is the day of the year, let the computer do it. The problem here is that you can write a program, enter a day of a certain year, and determine whether the Day is the day of the year?
Input
There are multiple groups of input data. The first row is the number of n groups of data, and the following n rows are n groups of data. Each group consists of three positive integers: year, month, and day, we ensure that each group of data is a valid date.
Output
The input date is the day of the year.
Sample Input
2
2009 1 1
2008 1 3
Sample output
1
3
Description
The time spent in college is really precious, and you have to hurry up with AC ^ _ ^. Do you know that today is the day of the year, let the computer do it. The problem here is that you can write a program, enter a day of a certain year, and determine whether the Day is the day of the year?
Input
There are multiple groups of input data. The first row is the number of n groups of data, and the following n rows are n groups of data. Each group consists of three positive integers: year, month, and day, we ensure that each group of data is a valid date.
Output
The input date is the day of the year.
Sample Input
2
2009 1 1
2008 1 3
Sample output
1
3
[Plain] # include <stdio. h>
Int cheakyear (int year );
Int main ()
{
Int I;
Int flag;
Int num;
Int year;
Int month;
Int day;
Int sum;
Int array [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 };
Scanf ("% d", & num );
While (num --)
{
Scanf ("% d", & year, & month, & day );
Sum = 0;
Flag = cheakyear (year );
For (I = 0; I <month; I ++)
{
Sum + = array [I];
}
Sum + = day;
If (flag & month> 2)
{
Sum ++;
}
Printf ("% d", sum );
If (num> 0)
{
Printf ("\ n ");
}
}
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 num;
Int year;
Int month;
Int day;
Int sum;
Int array [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 };
Scanf ("% d", & num );
While (num --)
{
Scanf ("% d", & year, & month, & day );
Sum = 0;
Flag = cheakyear (year );
For (I = 0; I <month; I ++)
{
Sum + = array [I];
}
Sum + = day;
If (flag & month> 2)
{
Sum ++;
}
Printf ("% d", sum );
If (num> 0)
{
Printf ("\ n ");
}
}
Return 0;
}
Int cheakyear (int year)
{
Int flag;
Flag = 0;
If (year % 400 = 0) | (year % 100! = 0 & year % 4 = 0 ))
{
Flag = 1;
}
Return flag;
}