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 |
就是这样的代码#include <iostream> using namespace std; const char inp[3][16] = {"10. zac 0", "0. pop 0", "10. zac 1995"}; char HaabMonths[19][8] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; char TzolkinDay[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; int HaabMonth2Index(char *m) { for(int i=0;i<19;i++) if (strcmp(m, HaabMonths[i])==0) return i; return -1; } int fromHaab(int d, char* m, int y) { int n = HaabMonth2Index(m); if (n == -1) return -1; return 365*y + 20*n + d; } void toTzolkin(int haab, int& d, char** m, int& y) { y = haab / 260; int n = haab % 260; d = (n % 13) + 1; *m = TzolkinDay[n % 20]; } struct Haab { int d; char m[16]; int y; }; struct Tzolkin { int d; char m[16]; int y; }; int main() { int d,y; char m[16]; char *pm; int n; scanf("%d",&n); if (n<=0) exit(1); cout << n << endl; for(int i=0;i<n;i++) { scanf("%d. %s %d", &d,m, &y); if (y>=5000) exit(1); int h = fromHaab(d,m,y); if (h==-1) cout <<"wrong\n"; else { toTzolkin(h,d,&pm,y); cout << d <<" " << pm <<" "<< y << 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