| ||||||||||
| 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 | |||||||||
自己搞定了 ,字符数组设错了应该为char hmon[10],tmon[10]就过了In Reply To:怎么还是出错啊?真的很郁闷!!我都检查好多遍了!!! Posted by:acmcc at 2004-05-07 01:23:50 > #include<stdio.h>
> #include<string.h>
> void main()
> {
> char hmon[1],tmon[1];//应该为char hmon[10],tmon[10]
> int hyear,tyear;
> int hday,tday;
> long total;
> int n,i,m,tmpmon;
> scanf("%d",&n);
> printf("%d\n",n);
> for(i=0;i<n;i++)
> {
> scanf("%d.%s%d",&hday,hmon,&hyear);
> if(!strcmp(hmon,"pop")) m=1;
> else if(!strcmp(hmon,"no")) m=2;
> else if(!strcmp(hmon,"zip")) m=3;
> else if(!strcmp(hmon,"zotz")) m=4;
> else if(!strcmp(hmon,"tzec")) m=5;
> else if(!strcmp(hmon,"xul")) m=6;
> else if(!strcmp(hmon,"yoxkin")) m=7;
> else if(!strcmp(hmon,"mol")) m=8;
> else if(!strcmp(hmon,"chen")) m=9;
> else if(!strcmp(hmon,"yax")) m=10;
> else if(!strcmp(hmon,"zac")) m=11;
> else if(!strcmp(hmon,"ceh")) m=12;
> else if(!strcmp(hmon,"mac")) m=13;
> else if(!strcmp(hmon,"kankin")) m=14;
> else if(!strcmp(hmon,"muan")) m=15;
> else if(!strcmp(hmon,"pax")) m=16;
> else if(!strcmp(hmon,"koyab")) m=17;
> else if(!strcmp(hmon,"cumhu")) m=18;
> else if(!strcmp(hmon,"uayet")) m=19;
> total=hyear*365+20*(m-1)+hday;
> tyear=total/260;
> tday=total%13+1;
> tmpmon=total%20;
> switch(tmpmon)
> {
> case 0: strcpy(tmon,"imix"); break;
> case 1: strcpy(tmon,"ik"); break;
> case 2: strcpy(tmon,"akbal"); break;
> case 3: strcpy(tmon,"kan"); break;
> case 4: strcpy(tmon,"chicchan"); break;
> case 5: strcpy(tmon,"cimi"); break;
> case 6: strcpy(tmon,"manik"); break;
> case 7: strcpy(tmon,"lamat"); break;
> case 8: strcpy(tmon,"muluk"); break;
> case 9: strcpy(tmon,"ok"); break;
> case 10: strcpy(tmon,"chuen"); break;
> case 11: strcpy(tmon,"eb"); break;
> case 12: strcpy(tmon,"ben"); break;
> case 13: strcpy(tmon,"ix"); break;
> case 14: strcpy(tmon,"mem"); break;
> case 15: strcpy(tmon,"cib"); break;
> case 16: strcpy(tmon,"caban"); break;
> case 17: strcpy(tmon,"eznab"); break;
> case 18: strcpy(tmon,"canac"); break;
> case 19: strcpy(tmon,"ahau"); break;
> }
> printf("%d %s %d\n",tday,tmon,tyear);
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator