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 <stdio.h> char* Tzo[] = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; int HaabMap[] = { 0, 0, 0, 0, 0, 0, 220, 0, 0, 160, 260, 0, 240, 0, 0, 300, 0, 0, 0, 0, 360, 0, 340, 0, 0, 200, 140, 20, 0, 0, 0, 0, 280, 40, 0, 0, 0, 0, 120, 60, 0, 0, 0, 100, 80 }; int findm(char* p) { int a = p[0] + p[1] - 194; if (24 == a) { if (p[0] == 'y') return 180; else return 320; } return HaabMap[a]; } int main() { int n, i=0; scanf("%d", &n); printf("%d\n", n); while (i++ < n) { int d, y; char m[10]; scanf("%d. %s %d", &d, m, &y); int days = y * 365 + findm(m) + d; int tm = days % 260; printf("%d %s %d\n", (tm % 13) + 1, Tzo[(tm % 20)], days / 260); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator