import java.util.Scanner;
public class LeapYear {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("请输入年份:");
int year = scan.nextInt();
boolean flag = (year%4==0 && year%100!=0) || year%400==0;
String str = flag ? year+"是闰年" : year+"不是闰年";
System.out.println(str);
}
}
刚开始学很多地方都不太明白只有请教大神们了,
求解释这两条语句如何判断的,尤其是第一条详细点,谢谢大神们了
boolean flag = (year%4==0 && year%100!=0) || year%400==0;
String str = flag ? year+"是闰年" : year+"不是闰年";
望远
慕粉3233872
相关分类