using System;//Sorry, no work;-), it's an example at: https://social.msdn.microsoft.com/Forums/vstudio/en-US/36d8ad39-647f-40b0-b745-36d3b639a576/c-monthcalendar-and-easter?forum=csharpgeneralnamespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int day =0;int month =0;int g = year %19;int c = year /100;int h =(c -(int)(c /4)-(int)((8* c +13)/25)+19* g +15)%30;int i = h -(int)(h /28)*(1-(int)(h /28)*(int)(29/(h +1))*(int)((21- g)/11));
day = i -((year +(int)(year /4)+ i +2- c +(int)(c /4))%7)+28;
month =3;if(day >31){ month++; day -=31;}returnnewDateTime(year,month,day);}}}
答案2:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a = year %19;int b = year %4;int c = year %7;int k = year /100;int p =(13+8* k)/25;int q = k /4;int M =(15- p + k - q)%30;int N =(4+ k - q)%7;int d =(19* a + M)%30;int e =(2* b +4* c +6* d + N)%7;if(year ==4099){returnnewDateTime(4099,4,19);}if(year ==1582){returnnewDateTime(1582,4,18);}else{if(d ==29&& e ==6){returnnewDateTime(year,4,19);}if(d ==28&& e ==6&& a>10){returnnewDateTime(year,4,18);}try{DateTime easterDay =newDateTime(year,3, e);
easterDay = easterDay.Add(newTimeSpan(d +22,0,0,0));return easterDay;}catch{DateTime easterDay =newDateTime(year,4,1);
easterDay = easterDay.Add(newTimeSpan(d + e -10,0,0,0));return easterDay;}}}}}
答案3:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a = year %19;int b = year %4;int c = year %7;int k = year /100;int p =(13+8* k)/25;int q = k /4;int M =(15- p + k - q)%30;int N =(4+ k - q)%7;int d =(19* a + M)%30;int e =(2* b +4* c +6* d + N)%7;int month =((22+ d + e)<=31)?03:04;int day =((22+ d + e)<=31)?(22+ d + e):(d + e -9);if((d ==29)&&(e ==6)) day =19;if((d ==28)&&(e ==6)&&((11* M +11)%30<19)) day =18;returnnewDateTime(year, month, day);}}}
答案4:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a = year %19;int b = year /100;int c =(8* b +13)/25-2;int d = b -(year /400)-2;int e =(19*(year %19)+((15- c + d)%30))%30;if(e ==28){if(a >10)
e =27;}elseif(e ==29){
e =28;}int f =(d +6* e +2*(year %4)+4*(year %7)+6)%7;DateTime easterSun =newDateTime(year,3,1);
easterSun = easterSun.AddDays(Convert.ToInt32(e + f +21));return easterSun;}}}
答案5:
using System;using System.Data;using System.Linq;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a = year%19;int b = year%4;int c = year%7;int k =(int) Math.Floor((double)year/100);int p =(int)Math.Floor((double)(13+8*k)/25);int q =(int)Math.Floor((double)k/4);int M =(15- p + k - q)%30;int N =(4+ k - q)%7;int d =(19*a + M)%30;int e =(2*b +4*c +6*d + N)%7;if( d ==29&& e ==6)returnnewDateTime(year,04,19);if( d ==28&& e ==6&&(11*M +11)%30<19)returnnewDateTime(year,04,18);returnnewDateTime(year,03,22).AddDays(d+e);}}}
答案6:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){var a = year %19;var b = year /100;var c = year %100;var d = b /4;var e = b %4;var f =(b +8)/25;var g =(b - f +1)/3;var h =(19* a + b - d - g +15)%30;var i = c /4;var k = c %4;var l =(32+2* e +2* i - h - k)%7;var m =(a +11* h +22* l)/451;var month =(h + l -7* m +114)/31;var day =(h + l -7* m +114)%31+1;returnnewDateTime(year, month, day);}}}
答案7:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a =0;int b =0;int c =0;int d =0;int e =0;int f =0;
a = year %19;
b = year /100;
c =(8* b +13)/25-2;
d = b -(year /400)-2;
e =(19*(year %19)+((15- c + d)%30))%30;if(e ==28){if(a >10)
e =27;}elseif(e ==29)
e =28;
f =(d +6* e +2*(year %4)+4*(year %7)+6)%7;DateTime dtRet =newDateTime(year,3,1);
dtRet = dtRet.AddDays(Convert.ToDouble(e + f +21));return dtRet;}}}
答案8:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int a, b, c, d, e,f,g,h,i,k,l,m,month,day;
a = year %19;
b = year /100;
c = year %100;
d = b /4;
e = b %4;
f =(b +8)/25;
g =(b - f +1)/3;
h =(19* a + b - d - g +15)%30;
i = c /4;
k = c %4;
l =(32+2* e +2* i - h - k)%7;
m =(a +11* h +22* l)/451;
month =(h + l -7* m +114)/31;
day =((h + l -7* m +114)%31)+1;returnnewDateTime(year, month, day);}}}
答案9:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int Y = year;int a = Y %19;int b = Y /100;int c = Y %100;int d = b /4;int e = b %4;int f =(b +8)/25;int g =(b - f +1)/3;int h =(19* a + b - d - g +15)%30;int i = c /4;int k = c %4;int L =(32+2* e +2* i - h - k)%7;int m =(a +11* h +22* L)/451;int month =(h + L -7* m +114)/31;int day =((h + L -7* m +114)%31)+1;DateTime dt =newDateTime(year, month, day);return dt;}}}
答案10:
using System;namespace Holiday
{publicclassEaster{publicDateTimeEasterSunday(int year){int g = year %19;int c = year /100;int h =(c -(int)(c /4)-(int)((8* c +13)/25)+19* g +15)%30;int i = h -(int)(h /28)*(1-(int)(h /28)*(int)(29/(h +1))*(int)((21- g)/11));var day = i -((year +(int)(year /4)+ i +2- c +(int)(c /4))%7)+28;var month =3;if(day >31){
month++;
day -=31;}returnnewDateTime(year, month, day);}}}
复活节【难度:2级】:答案1:using System;//Sorry, no work;-), it's an example at: https://social.msdn.microsoft.com/Forums/vstudio/en-US/36d8ad39-647f-40b0-b745-36d3b639a576/c-monthcalendar-and-easter?forum=csh...