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

要死人啦!为什么Rumtime ERROR!请高手指教,给个令我程序出错的数据也行啊

Posted by lzj_kkx at 2009-08-30 15:23:33 on Problem 1008
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char *MONTH_H[19] = 
{"pop","no","zip","zotz","tzec","tzec","xul","yoxkin","mol","chen","zac","ceh","mac","kankin","muan","pax","koyab",
"koyab","uayet"};
char *DAY_T[20] =
{"imix", "ik",  "akbal", "kan", "chicchan", "cimi", "manik","lamat","muluk", "ok", "chuen", "eb", "ben","ix","mem", 
"cib", "caban", "eznab", "canac", "ahau"};
void switchH(char nameMonthH[10],int *numMonthH);
void switchT(int numDayT,char nameDayT[10]);
main()
{
	char nameMonthH[10],nameDayT[10];
	int numMonthH,numDayT,dayH,yearH,preiodT,yearT,day,n;


	scanf("%d",&n);
	while(n--)
	{
		scanf("%d. %s %d",&dayH,nameMonthH,&yearH);

		switchH(nameMonthH,&numMonthH);
		day = yearH * 365 + (numMonthH - 1) * 20 + dayH + 1;

		yearT = day / 260;
		if(!(day % 260))
			yearT--;
	
			
		preiodT = day % 13;
		if(!preiodT)
			preiodT = 13;
		numDayT = day % 20;
		if(!numDayT)
			numDayT = 20;
		switchT(numDayT,nameDayT);

		printf("%d %s %d\n",preiodT,nameDayT,yearT);
	}	

}
void switchH(char nameMonthH[10],int *numMonthH)
{
	int i = 0;
	while(strcmp(nameMonthH,MONTH_H[i++]))
		if(i >= 20)
			printf("ERROR");
	*numMonthH = i;
	return ;
}
void switchT(int numDayT,char nameDayT[10])
{
	strcpy(nameDayT,DAY_T[numDayT - 1]);
	return;
}

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