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 <stdlib.h> #include <malloc.h> #include <string> using namespace std; const char* cal1[19] = {"pop","no","zip","zotz", "tzec","xul","yoxkin","mol", "chen","yax","zac","ceh", "mac","kankin","muan","pax", "koyab","cumhu","uayet"}; const char* cal2[20] = {"imix","ik","akbal","kan","chicchan", "cimi","manik","lamat","muluk","ok", "chuen","eb","ben","ix","mem", "cib","caban","eznab","canac","ahau"}; int getMonth(const char* name) { for(int i = 0; i < 19; i++) { if(strncmp(cal1[i],name,strlen(cal1[i])) == 0) { return i; } } return -1; } void main() { int num = 0; int* sum_days = NULL; int numberOfTheDay = 0; char month[10]; int year = 0; int index = 0; scanf("%d",&num); if((sum_days = (int*)malloc(sizeof(int)*num)) == NULL) { printf("malloc error!\n"); } for(int i = 0; i < num; i++) { scanf("%d. %s %d",&numberOfTheDay,month,&year); sum_days[i] = year*365+getMonth(month)*20+numberOfTheDay+1; } printf("%d\n",num); for(int j = 0; j < num; j++) { year = sum_days[j]/260; sum_days[j] %= 260; if(sum_days[j] == 0) { year-=1; numberOfTheDay = 13; index = 19; } else { numberOfTheDay = sum_days[j]%13; index = sum_days[j]%20-1; } printf("%d %s %d\n",numberOfTheDay,cal2[index],year); } free(sum_days); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator