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

1008问题请教,哪位大神看下,为什么一直说结果错误。谢谢谢谢

Posted by 17801066796 at 2017-05-22 20:09:41 on Problem 1008
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct calen
{
	int day;
	char mon[7];
	int year;
};
int main()
{
	
	char t[20][10] = {"imix", "ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
	char s[19][10] = { "pop","no","zip","zotz","tzec","xul","yoxkin", "mol","chen","yax","zac","ceh","mac","kankin" ,"muan" , "pax","koyab","cumhu","uayet" };
	int n, i, sum, m,m1,y1,y2,d1,j;
	char c;
	struct calen * ca;
	scanf("%d",&n);
	for (i = 0; i < n; i++)
	{
		ca = (struct calen*)malloc(n * sizeof(struct calen));
	}
	for (i = 0; i < n; i++)
	{
		scanf("%d%c %s %d",&ca[i].day,&c,&ca[i].mon,&ca[i].year);
	}
	printf("\n%d\n",n);
	for (i = 0; i < n; i++)
	{
		for (j = 0; i < 19; j++)
		{
			if (!strcmp(ca[i].mon,s[j]))
			{
				m = j + 1;
				break;
				printf("sdsagf\n");
				printf("%d\n",m);
			}
		}
		sum = ca[i].year * 365 + (m-1)* 20 + ca[i].day + 1;
		y1 = sum /260;
		y2 = sum % 260;
		m1 = sum%20;
		if (m1 == 0)
			m1 = m1 + 20;
		d1 = sum%13;
		if (d1 == 0)
			d1 = d1 + 13;
		if (y2 == 0 & sum>0)
		{ 
			y1 -= 1;;
			d1 = 13;
			m1 = 20;
		}
			
		printf("%d\t%s\t%d\n",d1,t[m1-1],y1);
	}
    return 0;
}


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