马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
你通过从书的数量和开发周期及运行速度来证明:net网页编程和ruby要比java简单。
程序为:
/*
西历夏历转换程式黄晓叫1995,7,25
prototype:intcalconv(structconvdate*);
structconvdate
{
intsource;==0则输出日期为西历,!=0则输出为夏历
intsolaryear;输入或输出之西积年份
intsolarmonth;西历月
intsolardate;西历日
intlunaryear;输入或输出之夏历年份
intlunarmonth;夏历月
intlunardate;夏历日
intweekday;该日为礼拜几(0==日曜日,1==礼拜一,...)
intkan;该日天干(0==甲,1==乙,...,9==癸)
intchih;该日地支(0==子,1==丑,...,11==亥)
};
呼唤时须设定souce的值,若为0则为西历转夏历,不然为夏历转西历.然後视
输出为西历或夏历来设定西历或夏历的年代日.转换後的年代日会填进布局中(农
历或西历),和该日为礼拜几,天干地支.
若函式的前往值为0暗示没有毛病,1为输出之年份毛病,2为输出之月份毛病,
3为输出之日期毛病.
输出之西积年须在1937-2031间
输出之夏历年须在1936-2030间
若须扩大,则增添lunarcal[]
*/
#definefirstyear1936/*thefirstyearinlunarcal[]*/
structconvdate
{
intsource;
intsolaryear;
intsolarmonth;
intsolardate;
intlunaryear;
intlunarmonth;
intlunardate;
intweekday;
intkan;
intchih;
};
structtaglunarcal
{
intbasedays;/*到西历1月1日到夏历正月月朔的积累日数*/
intintercalation;/*闰月月份.0==此年没有闰月*/
intbaseweekday;/*此年西历1月1日为礼拜几再减1*/
intbasekanchih;/*此年西历1月1日之干支序号减1*/
intmonthdays[13];/*此夏历年每个月之巨细,0==小月(29日),1==年夜月(30日)*/
};
structtaglunarcallunarcal[]={
{23,3,2,17,1,0,0,1,0,0,1,1,0,1,1,1,0},/*1936*/
{41,0,4,23,1,0,0,1,0,0,1,0,1,1,1,0,1},
{30,7,5,28,1,1,0,0,1,0,0,1,0,1,1,0,1},
{49,0,6,33,1,1,0,0,1,0,0,1,0,1,0,1,1},
{38,0,0,38,1,1,0,1,0,1,0,0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,1,0,1,0,1,0,1,0},
{21,2,6,54,0,1,0,1,0,1,0,1,1,0,1,0,1},
{40,0,0,59,0,1,0,0,1,0,1,1,0,1,1,0,1},/*2024*/
{28,6,2,5,1,0,1,0,0,1,0,1,0,1,1,1,0},
{47,0,3,10,1,0,1,0,0,1,0,0,1,1,1,0,1},
{36,0,4,15,1,1,0,1,0,0,1,0,0,1,1,0,1},
{25,5,5,20,1,1,1,0,1,0,0,1,0,0,1,1,0},/*2028*/
{43,0,0,26,1,1,0,1,0,1,0,1,0,0,1,0,1},
{32,0,1,31,1,1,0,1,1,0,1,0,1,0,1,0,0},
{22,3,2,36,0,1,1,0,1,0,1,1,0,1,0,1,0}};
#definelastyear(firstyear+sizeof(lunarcal)/sizeof(structtaglunarcal)-1)
/*西积年每个月之日数*/
intsolarcal[12]={31,28,31,30,31,30,31,31,30,31,30,31};
/*西积年每个月之积累日数,闰年与闰年*/
intsolardays[2][14]={
{0,31,59,90,120,151,181,212,243,273,304,334,365,396},
{0,31,60,91,121,152,182,213,244,274,305,335,366,397}};
/*求此西积年是不是为闰年,前往0为闰年,1为闰年*/
intgetleap(intyear)
{
if(year%400==0)
return1;
elseif(year%100==0)
return0;
elseif(year%4==0)
return1;
else
return0;
}
/*西历夏历转换*/
intcalconv(structconvdate*cd)
{
intleap,d,sm,y,im,l1,l2,acc,i,lm,kc;
if(cd->source==0)/*solar*/
{
if(cd->solaryear<=firstyear||cd->solaryear>lastyear)
return1;
sm=cd->solarmonth-1;
if(sm<0||sm>11)
return2;
leap=getleap(cd->solaryear);
if(sm==1)
d=leap+28;
else
d=solarcal[sm];
if(cd->solardate<1||cd->solardate>d)
return3;
y=cd->solaryear-firstyear;
acc=solardays[leap][sm]+cd->solardate;
cd->weekday=(acc+lunarcal[y].baseweekday)%7;
kc=acc+lunarcal[y].basekanchih;
cd->kan=kc%10;
cd->chih=kc%12;
if(acc<=lunarcal[y].basedays)
{
y--;
cd->lunaryear=cd->solaryear-1;
leap=getleap(cd->lunaryear);
sm+=12;
acc=solardays[leap][sm]+cd->solardate;
}
else
cd->lunaryear=cd->solaryear;
l1=lunarcal[y].basedays;
for(i=0;i<13;i++)
{
l2=l1+lunarcal[y].monthdays[i]+29;
if(acc<=l2)
break;
l1=l2;
}
cd->lunarmonth=i+1;
cd->lunardate=acc-l1;
im=lunarcal[y].intercalation;
if(im!=0&&cd->lunarmonth>im)
{
cd->lunarmonth--;
if(cd->lunarmonth==im)
cd->lunarmonth=-im;
}
if(cd->lunarmonth>12)
cd->lunarmonth-=12;
}
else/*lunar*/
{
if(cd->lunaryear<firstyear||cd->lunaryear>=lastyear)
return1;
y=cd->lunaryear-firstyear;
im=lunarcal[y].intercalation;
lm=cd->lunarmonth;
if(lm<0)
{
if(lm!=-im)
return2;
}
elseif(lm<1||lm>12)
return2;
if(im!=0)
{
if(lm>im)
lm++;
elseif(lm==-im)
lm=im+1;
}
lm--;
if(cd->lunardate>lunarcal[y].monthdays[lm]+29)
return3;
acc=lunarcal[y].basedays;
for(i=0;iacc+=lunarcal[y].monthdays[i]+29;
acc+=cd->lunardate;
leap=getleap(cd->lunaryear);
for(i=13;i>=0;i--)
if(acc>solardays[leap][i])
break;
cd->solardate=acc-solardays[leap][i];
if(i<=11)
{
cd->solaryear=cd->lunaryear;
cd->solarmonth=i+1;
}
else
{
cd->solaryear=cd->lunaryear+1;
cd->solarmonth=i-11;
}
leap=getleap(cd->solaryear);
y=cd->solaryear-firstyear;
acc=solardays[leap][cd->solarmonth-1]+cd->solardate;
cd->weekday=(acc+lunarcal[y].baseweekday)%7;
kc=acc+lunarcal[y].basekanchih;
cd->kan=kc%10;
cd->chih=kc%12;
}
return0;
}
JAVA学习必须明确这是一项投资,对于大多数的人来说,学习JAVA是为了就业,还有就是刚走向工作位置的朋友想尽快赶上工作的节奏。 |