package com.exercise.date; /** * @Author:Zxb * @Version:1.0 * @Date:2022/11/20-11:59 * @Since:jdk1.8 * @Description: */ public class date { public static void main(String[] args) { exercise(); } private static void exercise(){ int year=1990; int month=2; int totalDay=22; for (int y = 1990; y < year; y++) { if(y%4==0&&y%100!=0||y%400==0){ //闰年 totalDay+=366; }else{ totalDay+=365; } } for (int m = 1; m < month; m++) { switch (m){ case 1: case 3: case 5: case 7: case 8: case 10: totalDay+=31; break; case 2: if(year%4==0&&year%100!=0||year%400==0){ //闰年 totalDay+=29; }else{ totalDay+=28; } break; default: totalDay+=30; break; } } System.out.println("总天数:"+(totalDay-1)); } }
标签:totalDay,case,int,y%,break,1990.1,多少,exercise From: https://www.cnblogs.com/19981206-zxb/p/16908407.html