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:27行超简代码, 还能不能再简化呢?In Reply To:27行超简代码, 还能不能再简化呢? Posted by:1010321112 at 2011-09-23 18:44:41 > #include<iostream> > using namespace std; > #include<string.h> > char month[19][8]={ > "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", > "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", > "muan", "pax", "koyab", "cumhu", "uayet" }; > char month1[20][10]={ > "imix", "ik", "akbal", "kan", "chicchan", "cimi","manik", > "lamat", "muluk", "ok", "chuen", "eb","ben", "ix", "mem", > "cib", "caban", "eznab", "canac", "ahau" }; > int main() > { > int cas,day,m,year,sumday; > char mon[10]; > scanf("%d",&cas); > printf("%d\n",cas); > while(cas--) > { > scanf("%d. %s %d",&day,mon,&year); > m=0; > while(strcmp(month[m],mon)) m++; > sumday=365*year+20*m+day; > printf("%d %s %d\n",sumday%13+1,month1[sumday%20],sumday/260); > } > return 0; > } > > //////////////////////////////////////////////////////// > > //以下程序用到了map类 > /*#include<map> > #include<string> > #include<iostream> > using namespace std; > int main() > { > string month[]={ > "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", > "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", > "muan", "pax", "koyab", "cumhu", "uayet" }; > string month1[]={ > "imix", "ik", "akbal", "kan", "chicchan", "cimi","manik", > "lamat", "muluk", "ok", "chuen", "eb","ben", "ix", "mem", > "cib", "caban", "eznab", "canac", "ahau" }; > int cas,m,year,sumday;float day; > string mon; > scanf("%d",&cas); > printf("%d\n",cas); > map<string,int>mp; > for(int i=0;i<19;i++) > mp.insert(map<string, int>::value_type(month[i],i)); > while(cas--) > { > cin>>day>>mon>>year; > m=mp[mon]; > sumday=365*year+20*m+day; > cout<<sumday%13+1<<" "<<month1[sumday%20]<<" "<<sumday/260<<endl; > } > return 0; > } > */ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator