起初以为是自己输入输出方式有问题,百度发现自己没有考虑(yr%260==0&&!yr) 时需要减一。结果还是不对,最后发现自己数组少复制了一个字符串,很难受。但是题目中是没有的,这还是我看AC的代码发现的。以为肯定没错的地方错了,肯定错了的地方没错。。还是考虑不够,不熟悉规范。无话可说。
所以说这种题目给定的数据一定要仔细核对清楚,不然很浪费时间,而且基本上对编程能力没有什么增益。这还说明可以对自己自信点。。
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 char Haab[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}, 6 Tzolkin[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};//uayet 7 8 9 int main() 10 { 11 int N,i,j; 12 int num,yr,ndays,mon; 13 char name[10],ch; 14 scanf("%d",&N); 15 printf("%d ",N); 16 for(i=0;i<N;i++) 17 { 18 cin>>num>>ch>>name>>yr; 19 for(j=0;j<19;j++) 20 if(!strcmp(Haab[j],name)) 21 { 22 break; 23 } 24 ndays=365*yr+j*20+num; 25 yr=ndays/260; 26 num=ndays%260%13+1; 27 mon=ndays%260%20; 28 if(!ndays%260&&ndays) 29 yr--; 30 cout<<num<<' '<<Tzolkin[mon]<<' '<<yr<<endl; 31 } 32 return 0; 33 }