package demo01;
import java.util.*;
public class PanDuan {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("请输入年份:");
int year=scan.nextInt();
System.out.println("请输入月份:");
int month=scan.nextInt();
System.out.println("请输入日期");
int day=scan.nextInt();
int days=0;
int count=0;
if(month>0&&month<13&&day>0&&day<32){
for(int i=1;i<month;i++){
switch(i){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=31;
break;
case 4:
case 6:
case 9:
case 11:
days=30;
break;
case 2:
if((year%4==0&&year%100!=0)||year%400==0){
days=29;
}else{
days=28;
}
break;
}
count=count+days;
}
count=count+day;
}
System.out.println("今年是"+year+"的第"+count+"天");
}
}
输入年月日 判断是第几天
最新推荐文章于 2024-08-21 17:06:07 发布