Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
光阴似箭,日月如梭,大学的时间真是宝贵,要抓紧时间AC_。你知道今天是这一年第几天吗,掐指一算还是要算好久,呵呵还是让计算机来做吧。这里的问题就是让你来写一个程序,输入某年某月某日,判断这一天是这一年的第几天?
Input
输入第一行是数据的组数n<100,下面n行是n组数据,每组数据由3个正整数组成,分别为年、月、日,我们保证每组数据都是有效的日期。
Output
输出所输入的日期是这一年的第几天。
Sample Input
2
2009 1 1
2008 1 3
Sample Output
1
3
Hint
Source
本题注意要判断是否是瑞年
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int i,j;
int a,b,c,month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
scanf("%d",&n);
for(i=0;i<n;i++)
{
int days=0;
scanf("%d%d%d",&a,&b,&c);
if((a%4==0&&a%100!=0)||(a%4==0&&a%100==0&&a%400==0))
//判断是否是瑞年;
month[1]=29;
//若是瑞年,二月变为29天,即month[1]=29;
for(j=0;j<b-1;j++)
days+=month[j];
//现整月的天数累加;
printf("%d\n",days+c);
//不要忘记最后一个月的c天也要累加;
}
return 0;
}
2
2009 1 1
1
2008 1 3
3
Process returned 0 (0x0) execution time : 3.095 s
Press any key to continue.