Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

测试数据都对了、怎么会runtime error ,谁能给一组是我程序出错的数据啊?

Posted by lzj_kkx at 2009-05-10 22:41:43 on Problem 1008
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator