Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:要崩溃了测试数据都过一直RuntimeError~跪求大神拯救In Reply To:要崩溃了测试数据都过一直RuntimeError~跪求大神拯救 Posted by:DT_Lvhyy at 2013-03-30 09:30:22 > #include<stdio.h> > #include<string.h> > int main(void){ > char *Haab[19]={"pop", "no"," zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen","yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"}; > char *Tzolkin[20]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; > int t,day,year; > int Tday,Tyear,Tmonth,sum; > char tmp[10]; > scanf("%d",&t); > printf("%d\n",t); > getchar(); > while(t--){ > scanf("%d.%s%d",&day,tmp,&year); > int i; > for(i=0;;i++) > if(strcmp(Haab[i],tmp)==0) > break; > sum=20*i+day+year*365+1; > Tyear=sum/260; > if(sum%260==0) > Tyear--; > Tday=sum%13; > if(!Tday) > Tday=13; > Tmonth=sum%20; > if(!Tmonth) > Tmonth=20; > Tmonth-=1; > printf("%d %s %d\n",Tday,Tzolkin[Tmonth],Tyear); > } > return 0; > } 首先我不是大神,我做这个题还犯了没考虑到一年中最后一天的那个因素这么简单的错误。 就这样一开始是WA,后来测试数据都通过了,一提交,又是显示RE。很无语,查了好久,后来发现是我那个数组大小太小了,改掉之后就AC了。 后来,发现你这个帖子,我也按你的思路写了 就一次AC了! 最后经过我一行一行的找,一次一次的提交,发现你的Haab字符串数组中的第三个元素zip前有一个空格!!!!就是它让你RE的 ! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator