1182C language Experiment--a few days

Source: Internet
Author: User
Topic DescriptionTime flies, Riyuerusuo, the university is precious, to seize the time AC ^_^. Do you know that today is the first day of the year, pinch refers to a count or a long time, hehe or let the computer to do it. The problem here is that you write a program that enters a certain day of the year to determine which day is the first of the year. inputThe input data has more than one group, the first row is the number of groups N, the following n rows is n group of data, each group of data consists of 3 positive integers, respectively, the year, month, day, we guarantee that each group of data is a valid date. OutputThe date entered for the output is the day ordinal of the year. Sample Input
2
2009 1 1
2008 1 3
Sample Output
1
3



#include <stdio.h>
int main ()
{
int T, y, M, D, no, I;
int p[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
scanf ("%d", &t);
while (t--) {
scanf ("%d%d%d", &y, &m, &d);
if (y%400==0 | | (y%4==0&&y%100!=0))
P[2] = 29;
Else
P[2] = 28;
No = 0;
for (I=1; i<m; i++)
no = P[i];
no + = D;
printf ("%d\n", no);
}
return 0;
}

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.