Simple question.
#include <cstdio>#include<cstring>#include<cmath>#include<vector>#include<map>#include<queue>#include<stack>#include<algorithm>using namespacestd;Chara[ -][6]={ "Tret","Jan","Feb","Mar","Apr"," May","June","Jly"," the","Sep","Oct","Nov","Dec"};Charb[ -][6]={ "zzz","Tam","Hel","Maa","Huh","tou","Kes","Hei","ELO","Syy","Lok","Mer","Jou"};intMain () {intNChars[10000]; scanf ("%d",&N); GetChar (); for(intI=1; i<=n;i++) {gets (s); if(s[0]>='0'&&s[0]<='9') { intnum=0; for(intI=0; s[i];i++) num=num*Ten+s[i]-'0'; if(num<= A) printf ("%s\n", A[num]); Else if(num% -==0) printf ("%s\n", b[num/ -]); Elseprintf"%s%s\n", b[num/ -],a[num% -]); } Else { intp=-1; for(intI=0; s[i];i++)if(s[i]==' ') p=i; if(p==-1) { intnum=0; for(intI=0; i<= A; i++) if(strcmp (a[i],s) = =0) num=i; for(intI=1; i<= A; i++) if(strcmp (b[i],s) = =0) num= -*i; printf ("%d\n", num); } Else { intnum=0; Charop[Ten];intsz=0; for(intI=0; i<p;i++) op[sz++]=s[i]; op[sz]=0; for(intI=1; i<= A; i++) if(strcmp (b[i],op) = =0) num= -*i; SZ=0; for(inti=p+1; s[i];i++) op[sz++]=s[i]; op[sz]=0; for(intI=0; i<= A; i++) if(strcmp (a[i],op) = =0) num+=i; printf ("%d\n", num); } } } return 0;}
PAT (Advanced level) 1100. Mars Numbers (20)