1 #include <stdio.h>
2 #include <string.h>
3 char haab[18][10]={
4 "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen",
5 "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"
6 };
7 char tzo[20][10]={
8 "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok",
9 "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"
10 };
11
12 int main()
13 {
14 freopen("1.txt", "r", stdin);
15 int n, hday, hyear;
16 char hmonth[10];
17 scanf("%d", &n);
18 printf("%d\n", n);
19 while(n--)
20 {
21 charstring[30];
22 scanf("%d. %s %d", &hday, hmonth, &hyear);
23 int i;
24 for(i =0; i <18; i++)
25 if( strcmp(hmonth, haab[i]) ==0 )
26 break;
27 int total =365* hyear + i *20+ hday +1;
28
29 printf("%d %s %d\n", total%13==0?13:total%13, tzo[total%20==0?19:(total%20-1)], total%260==0?(total/260-1):total/260);
30 }
31 return0;
32 }
此题不难,但关键在于处理边界情况。开始没有注意到取模为0的情况,导致不停的WA。