package testaa;
import java.util.Scanner;
public class CountDay {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("輸出今年是第幾年:");
int year = scanner.nextInt();
System.out.print("輸出今年是第幾月:");
int month = scanner.nextInt();
System.out.print("輸出今年是第幾日:");
int day = scanner.nextInt();
int daysum = 0; // 天數(shù)
// 判斷 閏年計算方法 口訣:四年一閏,百年不閏,四百年再閏
int[] month1; //聲明數(shù)組
if (year % 400== 0||(year % 4== 0&&year%100!=0)) {
month1 = new int[]{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
}else{
month1 = new int[]{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
}
// 判斷這一天是第幾天
for (int i = 1; i <= month; i++) {
if ( i== 1) {
daysum = day;
} else {
daysum += month1[i - 2];
}
}
System.out.println("這一天是:"+year+"年"+month+"月"+day+"日");
System.out.println("這一天是這一年的第" + daysum + "天!");
}
}