日期计算

来源:互联网 发布:网络歌手排行榜2005 编辑:程序博客网 时间:2024/05/19 02:24

如题,输入一个日期,格式如:201010 24 ,判断这一天是这一年中的第几天。

输入

第一行输入一个数N(0<N<=100),表示有N组测试数据。后面的N行输入多组输入数据,每行的输入数据都是一个按题目要求格式输入的日期。

输出

每组输入数据的输出占一行,输出判断出的天数n

样例输入

3

2000 4 5

2001 5 4

2010 10 24

样例输出

96

124

297



public static void main(String[] args){Scanner sc=new Scanner(System.in);int a=sc.nextInt();int[][]i=new int[a][3];for(int b=0;b<a;b++){for(int c=0;c<3;c++){i[b][c]=sc.nextInt();}}int sum = 0;for(int b=0;b<a;b++){for(int c=0;c<2;c++){int feb = 28;if(i[b][0]%4==0 && i[b][0]%100!=0 || i[b][0]%400==0){feb=29;}switch(i[b][1]){case 1  : sum=i[b][2];break;case 2  : sum=31+i[b][2];break;case 3  : sum=31+feb+i[b][2];break;case 4  : sum=31+feb+31+i[b][2];break;case 5  : sum=31+feb+31+30+i[b][2];break;case 6  : sum=31+feb+31+30+31+i[b][2];break;case 7  : sum=31+feb+31+30+31+30+i[b][2];break;case 8  : sum=31+feb+31+30+31+30+31+i[b][2];break;case 9  : sum=31+feb+31+30+31+30+31+31+i[b][2];break;case 10 : sum=31+feb+31+30+31+30+31+31+30+i[b][2];break;case 11 : sum=31+feb+31+30+31+30+31+31+30+31+i[b][2];break;case 12 : sum=31+feb+31+30+31+30+31+31+30+31+30+i[b][2];break;}}System.out.println(sum);}}


0 0