Question one hundred and fourteen: several days

Source: Internet
Author: User

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

 
 


 

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.