您的位置:首页 > 编程语言 > C语言/C++

C语言实验——数日子 (sdut oj)

2017-01-29 12:44 253 查看




C语言实验——数日子

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

光阴似箭,日月如梭,大学的时间真是宝贵,要抓紧时间AC^_^。你知道今天是这一年第几天吗,掐指一算还是要算好久,呵呵还是让计算机来做吧。这里的问题就是让你来写一个程序,输入某年某月某日,判断这一天是这一年的第几天?




Input

输入数据有多组,第一行是数据的组数n,下面n行是n组数据,每组数据由3个正整数组成,分别为年、月、日,我们保证每组数据都是有效的日期。




Output

输出所输入的日期是这一年的第几天。




Example Input

2
2009 1 1
2008 1 3





Example Output

1
3



Hint


Author

参考代码

#include<stdio.h>
int main()
{
int m[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int y,moth,d;
int day;
int n;
int i;
scanf("%d",&n);
while(n--)
{
day = 0;
scanf("%d%d%d",&y,&moth,&d);
if((y % 400 == 0) || (y % 4 == 0 && y % 100 != 0))
m[1] = 29;
for(i = 0; i < moth - 1; i++)
{
day += m[i];
}
printf("%d\n",day + d);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  SDUT OJ c语言 数组