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:和我的有点相像,贴上代码供参考In Reply To:Re:和我的有点相像,贴上代码供参考 Posted by:wlh_flame at 2008-09-29 11:09:14 > 出错注意: > 1.输入输出格式完全没有问题 > 2.常量串书写无误 > 3.边界条件考虑无误,比如0和最后一个月之类,但是本题其实可以略去该步骤,因为各个情况实际上没有什么特殊之处。 > > #include "stdio.h" > > char *Haab[] = { > "pop", "no", "zip", "zotz", > "tzec", "xul", "yoxkin", "mol", > "chen", "yax", "zac", "ceh", > "mac", "kankin", "muan", "pax", > "koyab", "cumhu", "uayet" > }; > > char *Holly[] = { > "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", > "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" > }; > > int main() > { > int i, j, n; > int days; > char mon[8]; > char *str; > > int month, day, year; > int num; > > scanf("%d", &n); > printf("%d\n", n); //千万注意! > for (j = 0; j < n; j++) > { > days = 0; > scanf("%d.%s%d", &day, mon, &year); > > // resolve the month > str = mon; > for (i = 0; i < 19; i++) > { > if (Haab[i][0] == str[0] && Haab[i][1] == str[1]) { > break; > } > } > month = i; > > // resolve the day > days = year*365 + month*20 + day; > year = days / 260; > num = days % 13 + 1; > day = days % 20; > > // mapping > printf("%d %s %d\n", num, Holly[day], year); > } > > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator