注意数据: 当天数是260的倍数时,tzolkin年数要减一: wa了我4个小时 #include<stdio.h> #include<string.h> int main() //最郁闷的是:main打成mian,错的不明不白, //--------------------Configuration: 1008 - Win32 Debug-------------------- //Compiling... //1008.cpp //Linking... //LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main //Debug/dedigner_2010.exe : fatal error LNK1120: 1 unresolved externals //执行 link.exe 时出错. //1008.exe - 1 error(s), 0 warning(s) { long daylen; int t,i,h_day,h_year,t_day,t_year,tm,k; char h_name[10],haab[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}; char tzolkin[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; while(scanf("%d",&t)!=EOF) { printf("%d/n",t); for(i=1;i<=t;i++) { scanf("%d.%s%d",&h_day,h_name,&h_year); daylen=365*h_year; for(k=0;k<19;k++) if(strcmp(h_name,haab[k])==0) { daylen+=20*k; break; } daylen+=h_day+1; //前面一部分不难 t_year=daylen/260; //始 ,这一段也就是确定number(T=13)和name(T=20), if(daylen%260==0) t_year--; /*插:daylen原打成t_day,害的我郁闷了老半天,一时粗心,后果很严重*/ daylen%=260; //这样做简便很多,而我起先用了,for循环,搞得很复杂,而且也错了。 t_day=daylen%13; if(t_day==0) t_day=13; tm=daylen%20; if(tm==0) tm=20; tm--; //末 printf("%d %s %d/n",t_day,tzolkin[tm],t_year); } } return 0; }