做地推的网站,学编程的基础要具备什么,群推广,网站设计规划思路任何语言都有可能计算某一年是否为瑞年的方法#xff0c;也就是说一年有 366 天#xff0c;每隔4 年就出现一次。最基本的算法如下#xff1a;if year is divisible by 400 thenis_leap_yearelse if year is divisible by 100 thennot_leap_yearelse if year is divisible b…任何语言都有可能计算某一年是否为瑞年的方法也就是说一年有 366 天每隔4 年就出现一次。最基本的算法如下if year is divisible by 400 thenis_leap_yearelse if year is divisible by 100 thennot_leap_yearelse if year is divisible by 4 thenis_leap_yearelsenot_leap_year知道了这个基本算法那么起始与语言无关了这里就用JAVA 语言做一个讲解public class DateTimeExample {public static void main(String[] args) {DateTimeExample obj new DateTimeExample();System.out.println(1993 is a leap year : obj.isLeapYear(1993));System.out.println(1996 is a leap year : obj.isLeapYear(1996));System.out.println(2012 is a leap year : obj.isLeapYear(2012));}public boolean isLeapYear(int year) {if ((year % 400 0) || ((year % 4 0) (year % 100 ! 0))) {return true;} else {return false;}}}输出结果如下1993 is a leap year : false1996 is a leap year : true2012 is a leap year : true当然起始用Calendar 也是可以计算出来的.import java.util.GregorianCalendar;//...public boolean isLeapYear(int year) {GregorianCalendar cal (GregorianCalendar) GregorianCalendar.getInstance();return cal.isLeapYear(year);}