标签:style blog ar color os sp java for on
描述如题,输入一个日期,格式如:2010 10 24 ,判断这一天是这一年中的第几天。
3
2000 4 5
2001 5 4
2010 10 24
96
124
297
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner scanner=new Scanner(System.in); 7 int T; 8 int k; 9 int a; 10 int b; 11 int c; 12 int day[]={31,28,31,30,31,30,31,31,30,31,30,31}; 13 int i; 14 int sum; 15 16 T=scanner.nextInt(); 17 for(k=0;k<T;k++){ 18 a=scanner.nextInt(); 19 b=scanner.nextInt(); 20 c=scanner.nextInt(); 21 22 sum=0; 23 for(i=1;i<=b-1;i++) 24 sum+=day[i-1]; 25 26 sum+=c; 27 28 if(b>=3 && (a%400==0 || (a%4==0 && a%100!=0))) 29 sum++; 30 31 System.out.println(sum); 32 } 33 } 34 }
标签:style blog ar color os sp java for on
原文地址:http://www.cnblogs.com/zqxLonely/p/4131738.html