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

郁闷死了,总是WA,那位大虾能仗义相助?

Posted by silverdog at 2006-04-24 15:02:34 on Problem 1008
/////---  1008.  Maya Calender

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

#define  MAX  10000

  struct  Haab         /// 表示Haab日历的结构体类型
{
	int  day;
	char month[8];
	int year1;
} ;                

 struct    Tzolkin                              /// 表示Tzolkin日历的结构体类型
{
	int  daynum;
	char dayname[10];
	int year2;
} /*Tzolkin*/;

Haab in[MAX];
Tzolkin out[MAX];


int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", n);

		int i;

	for(i=1; i<=n; i++)       ////数组的0号空间不用
	{
		scanf("%d", &in[i].day);
		getchar();
		getchar();
		scanf("%s", in[i].month);
		getchar();
		scanf("%d", &in[i].year1);
	}

	int absday[MAX];

	for(i=1; i<=n; i++)
	{
		int monmark;
		if( !strcmp(in[i].month, "pop") )
			monmark = 1;
		else if( !strcmp(in[i].month, "no") )
			monmark = 2;
		else if( !strcmp(in[i].month, "zip") )
			monmark = 3;
		else if( !strcmp(in[i].month, "zotz") )
			monmark = 4;
		else if( !strcmp(in[i].month, "tzec") )
			monmark = 5;
		else if( !strcmp(in[i].month, "xul") )
			monmark = 6;
		else if( !strcmp(in[i].month, "yoxkin") )
			monmark = 7;
		else if( !strcmp(in[i].month, "mol") )
			monmark = 8;
		else if( !strcmp(in[i].month, "chen") )
			monmark = 9;
		else if( !strcmp(in[i].month, "yax") )
			monmark = 10;
		else if( !strcmp(in[i].month, "zac") )
			monmark = 11;
		else if( !strcmp(in[i].month, "ceh") )
			monmark = 12;
		else if( !strcmp(in[i].month, "mac") )
			monmark = 13;
		else if( !strcmp(in[i].month, "kankin") )
			monmark = 14;
		else if( !strcmp(in[i].month, "muan") )
			monmark = 15;
		else if( !strcmp(in[i].month, "pax") )
			monmark = 16;
		else if( !strcmp(in[i].month, "koyab") )
			monmark = 17;
		else if( !strcmp(in[i].month, "cumhu") )
			monmark = 18;
		else if( !strcmp(in[i].month, "uayet") )
			monmark = 19;
		else exit(1);
		absday[i] = in[i].year1 * 365 + (monmark - 1) * 20 + (in[i].day + 1);
	}///--- for循环, 算出所有的absday.

	for(i=1; i<=n; i++)
	{
		out[i].year2 = (absday[i]-1) / 260;

		int day_in_year;
		day_in_year = absday[i] % 260;
		if(absday[i] % 260 == 0)
			day_in_year = 260;

		int quot1;
		quot1 = day_in_year / 13;
		out[i].daynum = day_in_year - quot1 * 13;

		int quot2, daymark;
		quot2 = day_in_year /20;
		daymark = day_in_year - (quot2 * 20);
		
		if(daymark == 1)
			strcpy(out[i].dayname, "imix");
		else if(daymark == 2)
			strcpy(out[i].dayname, "ik");
		else if(daymark == 3)
			strcpy(out[i].dayname, "akbal");
		else if(daymark == 4)
			strcpy(out[i].dayname, "kan");
		else if(daymark == 5)
			strcpy(out[i].dayname, "chicchan");
		else if(daymark == 6)
			strcpy(out[i].dayname, "cimi");
		else if(daymark == 7)
			strcpy(out[i].dayname, "manik");
		else if(daymark == 8)
			strcpy(out[i].dayname, "lamat");
		else if(daymark == 9)
			strcpy(out[i].dayname, "muluk");
		else if(daymark == 10)
			strcpy(out[i].dayname, "ok");
		else if(daymark == 11)
			strcpy(out[i].dayname, "chuen");
		else if(daymark == 12)
			strcpy(out[i].dayname, "eb");
		else if(daymark == 13)
			strcpy(out[i].dayname, "ben");
		else if(daymark == 14)
			strcpy(out[i].dayname, "ix");
		else if(daymark == 15)
			strcpy(out[i].dayname, "mem");
		else if(daymark == 16)
			strcpy(out[i].dayname, "cib");
		else if(daymark == 17)
			strcpy(out[i].dayname, "caban");
		else if(daymark == 18)
			strcpy(out[i].dayname, "eznab");
		else if(daymark == 19)
			strcpy(out[i].dayname, "canac");
		else if(daymark == 20)
			strcpy(out[i].dayname, "ahau");

	}////---  for循环,计算输出值

	for(i=1; i<=n; i++)
		printf("%d %s %d\n", out[i].daynum, out[i].dayname, out[i].year2);
	
	
		
	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