import java.util.Scanner; public class Main { public static boolean isLeapYear(int year) { return year % 100 == 0 ? year % 400 == 0 : year % 4 == 0; } public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int year = 0; while (in.hasNext()) { year = in.nextInt(); System.out.println("请输入任意一个年份:"); if (year < 0) { System.out.println("输入为错误的年份"); } else { if (isLeapYear(year)) System.out.println(year + "是闰年!"); else System.out.println(year + "是平年"); } } in.close(); } }
点赞 2

相关推荐

双尔:反手回一个很抱歉,经过慎重考虑,您与我的预期暂不匹配,感谢您的投递
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务