public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.print("请输入年份:");
int year=scan.nextInt();
System.out.print("请输入月份:");
int month=scan.nextInt();
System.out.print("请输入日期:");
int day=scan.nextInt();
int number[]={31,28,31,30,31,30,31,31,30,31,30,31};
month=month-1;
if((year%4==0&&year%100==0)||year%400==0){
for(int i=0;i<month;i++){
day+=number[i];
}
}
else{
number[1]=29;
for(int i=0;i<month;i++){
day+=number[i];
}
}
System.out.println("是当年的第"+day);
}
当输入一个年月份和日期的时候,输出是今年的第多少天
最新推荐文章于 2022-03-15 17:39:32 发布