我们在小学时老师教我们能被 4 整除的就是闰年,等到我们大了,又有人告诉我们能被 4 整除,但不能被 100 整除的都是闰年。那这是怎么回事?
其实,从严格的意义来讲,这两个都不准确。
根据维基百科,我们可以知道一标准年为 365天 5时 48分 45.5秒。
那么这就意味着时间存在着人为的误差,由于时间秒的定义是已经规定的标准,不可能改变
标准年: 365/5/48/45.5 余有:5/48/45.5 -- 格式 时/分/秒 这时余有是正(个人理解) 用于给每一个4进制年一天, 但是每一个 4进制 就会有 - 0/44/58的差错 4 X 余有 20/192/182 -> 20/|3 + 12/|3 + 2 -> 23/15/2 余有:- 0/44/58 -- 同理,一百年时这个差错已经很大了,需要在 100年的 366天变为 365天, 这时,我们就有了余有:5/15/50 100 X -0/1100/1450 -> -0/|18 + 20/|24 + 10 -> -18/44/10 余有:5/15/50 -- 以此循环往复 400 X 20/60/200 -> 20/|1 + 0/|3 + 20 -> 21/3/20 余有:-2/56/40 3200 X -16/448/320 -> -16/|7 + 28/|5 + 20 -> -23/33/20 余有:0/26/40 X 0/1404/2160/ -> 0/|23 + 24/|36 + 0/ -> 24/0/0 余有:0/0/0 这是我个人的学习心得
#include
int years; _Bool goSign; _Bool leapYearSign; void inputYear(); _Bool judgeLeapYear(int years); void display(); void inputYear() { printf("please input years:\n"); scanf("%d",&years); //Warning Writing format scanf("%d \n",&years); } _Bool judgeLeapYear(int years) { printf("judging......\n"); if(years %4 == 0) { if(years %100 == 0) { if(years %400 == 0) { if(years %3200 == 0) { if(years % == 0) leapYearSign = 1; else leapYearSign = 0; } else leapYearSign = 1; } else leapYearSign = 0; } else leapYearSign = 1; } else leapYearSign = 0; printf("judged\n"); } void display() { printf("year: %d is LeapYear: %d\n",years,leapYearSign); printf("Do you want go down, Yes-1,No-0\n"); scanf("%d",&goSign); } int main() { do { inputYear(); judgeLeapYear(years); display(); }while(goSign == 1); return 0; }
另附图片

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/215777.html原文链接:https://javaforall.net
