/*
*/
public class Easter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in)
while (true) {
System.out.println("请输入你要查唤笑询的年份:")
int y = sc.nextInt()
int answer = easterCal(y)
if (answer >0) {
print(y, 4, answer)
} else {
print(y, 3, 31 + answer)
}
}
}
/*
*
*功能描述 打印输出中链槐查询年份的复活节日期
* @author Congee
* @date
* @param
* @return
*/
public static void print(int year, int mon, int d) {
System.out.println(year + "年的复活节是" + mon + "月" + d + "日")
System.out.println("卖友=====================")
}
/*
*
*功能描述 复活节算法
* @author Congee
* @date
* @param
* @return
*/
public static int easterCal(int y){
int n = y - 1900
int a = n % 19
int q = n / 4
int b = (7 * a + 1) / 19
int m = (11 * a + 4 - b) % 29
int w = (n + q + 31 - m) % 7
int answer = 25 - m - w
return answer
}
}
happy easter holiday
复活节快乐
复活节是纪念耶稣基督在十字架受刑死后复活的节日,西方信基督教的国家都过这个节。
耶稣(英文原句为:“Easter,anniversary of the Resurrection of Christ,observed on the first Sunday after a full moon on or after 21 March.”)
[注:原来,复活节那一天,是经由三个历法(分别是西历、中国阴历、星期)合并出来的,怪不得它会如此飘忽不定了!]
日期算法
编辑
复活节彩蛋复芦迅活节是西方传统的节日,公元325年尼西亚宗教会议规定,每年过春分月圆后的第一个星期天为复活节。其日期是不固定的,通常是要查看日历才能知道。
现在有一个简便的算法供大家参考!
年份只限于1900年到2099年
NO.1设要求的那一年是Y年,从Y减去1900,其差记为N。
NO.2用19作除数去除N,余数记为A。
NO.3用4作除数去除N,不管余数,把商记为Q。
NO.4用19去除7A+1,把商记为B,不管余数。
NO.5用29去除11A+4-B,余数记为M。
NO.6用7去除N+Q+31-M,余数记为W。
NO.7计算25-M-W。
得出答数即可定出复活节的日期。若为正数,月份为4月,如为负数,月份为3月。若为0,则为3月31日。
现在我们选两个年份来实例计算一遍。
例1.1983年的复活节日期。
1.1983-1900=83,N=83
2.N/19=4余7,A=7
3.N/4=20余3,Q=20
4.7A+1=50,50/19=2余12,B=2
5.11A+4-B=79,79/29=2余21,M=21
6.N+Q+31-M=113,113/7=16余1,W=1
7.25-M-W=3
由此可知,1983年的复活节日期是4月3日。
例2.2008年,中国将在北京举办奥运会,那一年复活节是哪一天呢?
1.2008-1900=108,N=108
2.N/19=5余13,A=13
3.N/4=27,Q=27
4.7A+1=92,92/19=4余16,B=4
5.11A+4-B=143,143/29=4余27,M=27
6.N+Q+31-M=139,139/7=19余6,W=6
7.25-M-W=-8,31-8=23
所以该年复活节日期是3月23日。
按照复杂的天文历法分析与计算,最早的复活节日期是3月22日,上一次出现是在1818年,而且要到2285年才会再度出现。最晚的日期是在4月25日,上一次出现是在1943年,要到2038年才会出现。
用MATLAB计算2007年复活节日期,程序如下:
y=2007;
n=y-1900;
a=mod(n,19);
q=floor(n/4);
b=floor((7*a+1)/19);
m=mod(11*a+4-b,29);
w=mod(n+q+31-m,7);
d = 25-m-w
最昂贵的复活节蛋组图(7)
得到d=8,即2007年4月8日。2006年4月16日,2008年3月23日,2009年4月12日,2010年4月4日。
由于时间关系,我已经计了一百年内的复活节,这是西欧的计法,东欧及俄罗斯不适用。祝大家在以后的复活节快乐!
23/3/2008 17/4/2033 14/4/2058 4/4/2083
12/4/2009 9/4/陪搏此2034 30/3/2059 26/3/2084
4/4/2010 25/3/2035 18/4/2060 15/4/2085
24/4/2011 13/4/2036 10/4/银举2061 31/3/2086
8/4/20125/4/203726/3/206220/4/2087
31/3/201325/4/203815/4/206311/4/2088
20/4/201410/4/20396/4/20643/4/2089
5/4/20151/4/204029/3/206516/4/2090
27/3/201621/4/204111/4/20668/4/2091
16/4/20176/4/20423/4/206730/3/2092
1/4/201829/3/204322/4/206812/4/2093
21/4/201917/4/204414/4/20694/4/2094
12/4/20209/4/204530/3/207024/4/2095
4/4/202125/3/204619/4/207115/4/2096
17/4/202214/4/204710/4/207231/3/2097
9/4/20235/4/204826/3/207320/4/2098
31/3/202418/4/204915/4/207412/4/2099
20/4/202510/4/20507/4/207528/3/2100
5/4/20262/4/205119/4/207617/4/2101
28/3/202721/4/205211/4/20779/4/2102
16/4/20286/4/20533/4/207825/3/2103
1/4/202929/3/205423/4/207913/4/2104
21/4/203018/4/20557/4/20805/4/2105
13/4/20312/4/205630/3/208118/4/2106
28/3/203222/4/205719/4/208210/4/2107
1/4/2108
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)