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

谁能告诉我为什么?

Posted by 20094154 at 2012-03-27 14:15:50 on Problem 1008 and last updated at 2012-03-27 14:17:13
#include <stdio.h>
#include <string.h>

int main()
{
	char Haab[19][8]={
		"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin",
		"mol", "chen", "yax", "zac", "ceh", "mac", "kankin",
		"muan", "pax", "koyab", "cumhu", "uayet" };
	char Tzolkin[20][10]={
		"imix", "ik", "akbal", "kan", "chicchan", "cimi","manik",
		"lamat", "muluk", "ok", "chuen", "eb","ben", "ix", "mem",
		"cib", "caban", "eznab", "canac", "ahau" };

	int n, year, day;
	int i, sum;
	char month[25];
	scanf("%d",&n);//只有这个地方不同
	{
		printf("%d\n",n);
		while(n--)
		{
			scanf("%d. %s %d",&day,month,&year);
			i = 0;
			while(strcmp(Haab[i],month) != 0)
			{
				i++;
			}
			sum = year*365 + day + i*20;
			printf("%d %s %d\n", sum%13+1, Tzolkin[sum%20], sum/260);
		}
	}
	return 0;
}
这个代码能AC


#include <stdio.h>
#include <string.h>

int main()
{
	char Haab[19][8]={
		"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin",
		"mol", "chen", "yax", "zac", "ceh", "mac", "kankin",
		"muan", "pax", "koyab", "cumhu", "uayet" };
	char Tzolkin[20][10]={
		"imix", "ik", "akbal", "kan", "chicchan", "cimi","manik",
		"lamat", "muluk", "ok", "chuen", "eb","ben", "ix", "mem",
		"cib", "caban", "eznab", "canac", "ahau" };

	int n, year, day;
	int i, sum;
	char month[25];
	while(scanf("%d",&n)!=EOF)//只有这个地方不同
	{
		printf("%d\n",n);
		while(n--)
		{
			scanf("%d. %s %d",&day,month,&year);
			i = 0;
			while(strcmp(Haab[i],month) != 0)
			{
				i++;
			}
			sum = year*365 + day + i*20;
			printf("%d %s %d\n", sum%13+1, Tzolkin[sum%20], sum/260);
		}
	}
	return 0;
}
这个代码就runtime error

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