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 |
WA到崩溃,大家给的测试数据也都通过了,求大神带看~!!#include "stdio.h" #include "string.h" int main(int argc, char * argv[]) { int line,count; int tranHaab(char *mon); void tranTzolkin(int month, char *mon); scanf("%d", &line); printf("%d\n", line); int day = 0,month = 0,year = 0; char mon[10] = {0}; int sum; while (line != 0){ scanf("%d.%s %d",&day,mon,&year); month = tranHaab(mon); sum = year * 365 + (month - 1) * 20 + day + 1; if ( sum/260 == 1){ day = 13; tranTzolkin(20, mon); year = 0; } else if ( sum % 260== 0){ day = 13; tranTzolkin(20, mon); year = sum / 260 - 1; } else{ day = (sum % 260) % 13; if (day == 0) day = 13; tranTzolkin((sum % 260) % 20, mon); year = sum / 260; } printf("%d %s %d\n", day, mon, year); line--; } return 0; } int tranHaab(char *mon){ int month=0; if (strcmp(mon,"pop")==0) month = 1; else if (strcmp(mon, "no") == 0) month = 2; else if (strcmp(mon, "zip") == 0) month = 3; else if (strcmp(mon, "zotz") == 0) month = 4; else if (strcmp(mon, "tzec") == 0) month = 5; else if (strcmp(mon, "xul") == 0) month = 6; else if (strcmp(mon, "yoxkin") == 0) month = 7; else if (strcmp(mon, "mol") == 0) month = 8; else if (strcmp(mon, "chen") == 0) month = 9; else if (strcmp(mon, "yax") == 0) month = 10; else if (strcmp(mon, "zac") == 0) month = 11; else if (strcmp(mon, "ceh") == 0) month = 12; else if (strcmp(mon, "mac") == 0) month = 13; else if (strcmp(mon, "kankin") == 0) month = 14; else if (strcmp(mon, "muan") == 0) month = 15; else if (strcmp(mon, "pax") == 0) month = 16; else if (strcmp(mon, "koyab") == 0) month = 17; else if (strcmp(mon, "cumbu") == 0) month = 18; else if (strcmp(mon, "uayet") == 0) month = 19; return month; } void tranTzolkin(int month, char *mon){ switch (month) { case 1:strcpy(mon, "imix"); break; case 2:strcpy(mon, "ik"); break; case 3:strcpy(mon, "akbal"); break; case 4:strcpy(mon, "kan"); break; case 5:strcpy(mon, "chicchan"); break; case 6:strcpy(mon, "cimi"); break; case 7:strcpy(mon, "manik"); break; case 8:strcpy(mon, "lamat"); break; case 9:strcpy(mon, "muluk"); break; case 10:strcpy(mon, "ok"); break; case 11:strcpy(mon, "chuen"); break; case 12:strcpy(mon, "eb"); break; case 13:strcpy(mon, "ben"); break; case 14:strcpy(mon, "ix"); break; case 15:strcpy(mon, "mem"); break; case 16:strcpy(mon, "cib"); break; case 17:strcpy(mon, "caban"); break; case 18:strcpy(mon, "eznab"); break; case 19:strcpy(mon, "canac"); break; case 20:strcpy(mon, "ahau"); break; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator