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 |
我是陆志杰——卡卡西 测试数据都对,可怎么会rum time error ,跪求高人相助!#include <stdio.h> #include <string.h> #include <stdlib.h> #define YEAR_H 365 #define MONTH_H 20 #define YEAR_T 260 #define DATE_T 20 #define PERIOD_T 13 typedef struct time { int days; char name_Month_H[10]; int year_H,num_Date_H,num_Month_H; int year_T; int num_Date_T ; int num_Period_T ; char *name_Date_T; } time; time *head; void creat(time *list); void print(time *head,int count); int switch_Month_H(char name_Month_H[]); char *switch_Date_T(int num_Date_T); main() { int count,i; scanf("%d",&count); i = count; head = (time *)malloc(sizeof(count)); while(i) { creat(head + i); i--; } printf("%d\n",count); print(head,count); } void creat(time *list) { scanf("%d. %s %d",&list->num_Date_H,list->name_Month_H,&list->year_H); list->num_Month_H = switch_Month_H(list->name_Month_H); list->days = list->year_H * YEAR_H + (list->num_Month_H - 1) * MONTH_H + list->num_Date_H + 1; list->year_T = list->days / YEAR_T; if(list->days % YEAR_T == 0) list->year_T--; list->num_Date_T = list->days % DATE_T; if(!list->num_Date_T) list->num_Date_T = DATE_T; list->num_Period_T = list->days % PERIOD_T; if(!list->num_Period_T) list->num_Period_T = PERIOD_T; list->name_Date_T = switch_Date_T(list->num_Date_T); return; } void print(time *head,int count) { int i = count; time *p; while(i) { p = head + i; printf("%d %s %d\n",p->num_Period_T,p->name_Date_T,p->year_T); i--; } return; } int switch_Month_H(char name_Month_H[]) { int i; char *name[20] = { "pop","no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan","pax", "koyab", "cumhu", "uayet" }; for(i = 0;i < 20;i++) { if(!strcmp(name_Month_H,name[i])) break; } return i+1; } char *switch_Date_T(int num_Date_T) { char *date[20] = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; return date[num_Date_T - 1]; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator