1 package FushiExam; 2 import java.util.*; 3 public class Text_14 { 4 5 public static void main(String[] args) { 6 // 输入某年某月某日,判断这一天是这一年的第几天 7 Scanner scan=new Scanner(System.in); 8 int year=scan.nextInt(); 9 int month=scan.nextInt(); 10 int day=scan.nextInt(); 11 int total=0; 12 if(year%400==0||(year%100!=0&&year%4==0)) {//闰年 13 int[] months= {31,29,31,30,31,30,31,31,30,31,30,31}; 14 for(int i=0;i<month-1;i++) { 15 total=total+months[i]; 16 } 17 total=total+day; 18 System.out.println("这是这一年的第"+total+"天"); 19 } 20 else {//非闰年 21 int[] months= {31,28,31,30,31,30,31,31,30,31,30,31}; 22 for(int i=0;i<month-1;i++) { 23 total=total+months[i]; 24 } 25 total=total+day; 26 System.out.println("这是这一年的第"+total+"天"); 27 } 28 29 30 31 } 32 33 }