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; }
相关文章推荐
- C语言实验——从大到小输出a、b、c(选择结构)(sdut oj)
- C语言实验——计算A+B(顺序结构)(sdut oj)
- C语言实验——交换两个整数的值(顺序结构)(sdut oj)
- C语言实验——大小写转换 (sdut oj)
- C语言实验——圆周率 (sdut oj)
- C语言实验——某年某月的天数 (sdut oj)
- C语言实验——合法的C标识符 (sdut oj)
- C语言实验——求阶乘(循环结构) (sdut oj)
- C语言实验——最值 (sdut oj)
- C语言实验——时间间隔 (sdut oj)
- C语言实验——数日子
- C语言实验——数日子
- 2010年度总结-在淘宝的半年日子
- 代码青春之我在河北软件的日子
- 难熬的一段日子
- 在微软实习的日子
- 今天是2011年6月9日,是我的博客开通的日子... ...
- 在烟台的日子2011-08-09
- 程序一点点地写,日子一天天地过。
- 玩DB2的那段日子