题目8 今年的第几天?
1 import java.util.Scanner; 2 3 public class Main{ 4 private static int isLeap(int year){ 5 if(year%4==0&&year%100!=0||year%400==0) return 1; 6 else return 0; 7 } 8 private static int[][] dayOfMonth={ 9 {0,0}, 10 {31,31}, 11 {28,29}, 12 {31,31}, 13 {30,30}, 14 {31,31}, 15 {30,30}, 16 {31,31}, 17 {31,31}, 18 {30,30}, 19 {31,31}, 20 {30,30}, 21 {31,31}, 22 }; 23 public static void main(String[] args) { 24 Scanner in=new Scanner(System.in); 25 while(in.hasNext()){ 26 int year=in.nextInt(); 27 int month=in.nextInt(); 28 int day=in.nextInt(); 29 int sum=0; 30 for(int i=1;i<month;i++){ 31 sum+=dayOfMonth[i][isLeap(year)]; 32 } 33 sum+=day; 34 System.out.println(sum); 35 } 36 } 37 }