Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 64696 | Accepted: 19939 |
Description
Input
Output
Sample Input
3 10. zac 0 0. pop 0 10. zac 1995
Sample Output
3 3 chuen 0 1 imix 0 9 cimi 2801 my god!终于给AC了,对于我这样一个十足的菜鸟来说,这道题给我的收获太多了. 第一:字符串赋值问题: 给一个字符型数组赋值可以有3种方法(以abc为例): (1)char a[]={'a','b','c'}; (2)char a[]={"abc"}; (3)strcpy(a,"abc");(数组a必须要声明,char a[max]) 第二:switch(i) { case i: ...; . ; . ; . ; default:....; } switch()函数类问题需要注意:函数中i必须是数字,单个字符也可以,但是不能是字符串。 第三:strcmp()函数类问题 strcmp()比较的是两个字符串的大小(按照从前到后按ASCII值比较),形式是strcmp(s1,s2) if(strcmp(s1,s2)>0) s1>s2; if(strcmp(s1,s2)==0) s1=s2; if(strcmp(s1,s2)<0) s1#include
#include struct haab { int day; char month[20]; int year; }haab; struct tzolkin { int month; int year; }tzolkin; int main (void) { // freopen("1008.txt","r",stdin); int n,i,m,days,d; while(scanf("%d",&n)!=EOF) { printf("%d\n",n); for(i=1;i<=n;i++) { scanf("%d.%s%d",&haab.day,haab.month,&haab.year); if(strcmp(haab.month,"pop")==0) m=1; else if(strcmp(haab.month,"no")==0) m=2; else if(strcmp(haab.month,"zip")==0) m=3; else if(strcmp(haab.month,"zotz")==0) m=4; else if(strcmp(haab.month,"tzec")==0)m=5; else if(strcmp(haab.month,"xul")==0) m=6; else if(strcmp(haab.month,"yoxkin")==0)m=7; else if(strcmp(haab.month,"mol")==0) m=8; else if(strcmp(haab.month,"chen")==0)m=9; else if(strcmp(haab.month,"yax")==0) m=10; else if(strcmp(haab.month,"zac")==0) m=11; else if(strcmp(haab.month,"ceh")==0) m=12; else if(strcmp(haab.month,"mac")==0) m=13; else if(strcmp(haab.month,"kankin")==0) m=14; else if(strcmp(haab.month,"muan")==0) m=15; else if(strcmp(haab.month,"pax")==0)m=16; else if(strcmp(haab.month,"koyab")==0) m=17; else if(strcmp(haab.month,"cumhu")==0) m=18; else m=19; // printf("%d ",m); days=haab.year*365+(m-1)*20+haab.day+1; // printf("%d ",days); if(days%260==0) tzolkin.year=days/260-1; else tzolkin.year=days/260; // tzolkin.month=days%260/20; if(days%260%13==0) tzolkin.month=13; else tzolkin.month=days%260%13; printf("%d ",tzolkin.month); d=days%260%20; if(d==1) printf("imix "); else if(d==2) printf("ik "); else if(d==3) printf("akbal "); else if(d==4) printf("kan "); else if(d==5) printf("chicchan "); else if(d==6) printf("cimi "); else if(d==7) printf("manik "); else if(d==8) printf("lamat "); else if(d==9) printf("muluk "); else if(d==10) printf("ok "); else if(d==11) printf("chuen "); else if(d==12) printf("eb "); else if(d==13) printf("ben "); else if(d==14) printf("ix "); else if(d==15) printf("mem "); else if(d==16) printf("cib "); else if(d==17) printf("caban "); else if(d==18) printf("eznab "); else if(d==19) printf("canac "); else printf("ahau "); printf("%d\n",tzolkin.year); } } return 0; }