symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理

历法的转换。

 1 #include <stdio.h>
 2 #include <math.h>
 3 #include <string.h>
 4 char Haab[19][10]={
 5     "pop","no","zip","zotz","tzec","xul","yoxkin","mol",
 6     "chen","yax","zac","ceh","mac","kankin","muan","pax",
 7     "koyab","cumhu","uayet"
 8 };
 9 char Tzolkin[20][10]={
10     "imix","ik","akbal","kan","chicchan","cimi","manik",
11     "lamat","muluk","ok","chuen","eb","ben","ix","mem",
12     "cib","caban","eznab","canac","ahau"
13 };
14 int count(int day,char month[],int year){
15     int tot=0;
16     tot+=(day+1);
17     int i;
18     for(i=0;i<19;++i){
19         if(strcmp(month,Haab[i])==0){
20             tot+=(i*20);
21             break;
22         }
23     }
24     tot+=(year*365);
25     return tot;
26 }
27 int main(){
28     int t,i,tot;
29     int day,year;
30     int m;
31     char month[10];
32     while(~scanf("%d",&t)){
33         printf("%d\n",t);
34         for(i=0;i<t;++i){
35             scanf("%d. %s %d",&day,month,&year);
36             tot=count(day,month,year);
37             m=(tot-1)%20;
38             day=(tot-1)%13;
39             day++;
40             if(day>13){
41                 day=(day%13)+1;
42             }else
43             year=(tot-1)/260;
44             printf("%d %s %d\n",day,Tzolkin[m],year);
45         }
46     }
47     return 0;
48 }

 

posted on 2014-01-02 21:54  symons  阅读(144)  评论(0编辑  收藏  举报