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 lzj_kkx at 2009-04-24 13:35:46 on Problem 1008
总天数days =days = year_H * YEAR_H + (num_Month_H - 1) * MONTH_H + num_Date_H + ;
 代码如下:
#include <stdio.h>
#include <string.h>

#define YEAR_H 365
#define MONTH_H 20

#define YEAR_T 260
#define DATE_T 20 
#define PERIOD_T 13


int switch_Month_H(char name_Month_H[]);
char *switch_Date_T(int num_Date_T);
main()
{
	int days;
	char name_Month_H[10];
	int year_H,num_Date_H,num_Month_H;

	
	int year_T; 
	int date; 
	int num_Date_T ;
	int num_Period_T ;
	char *name_Date_T;


	scanf("%d. %s %d",&num_Date_H,name_Month_H,&year_H);
	num_Month_H = switch_Month_H(name_Month_H);
	
	days = year_H * YEAR_H + (num_Month_H - 1) * MONTH_H + num_Date_H + ;

	 year_T = days / YEAR_T;
	 date = days % YEAR_H;
	 
	 num_Date_T = date % DATE_T;
	 if(!num_Date_T)
		num_Date_T = DATE_T;

	 num_Period_T = date % PERIOD_T;
	 if(!num_Period_T)
		 num_Period_T = PERIOD_T;
	 name_Date_T = switch_Date_T(num_Date_T);

	 printf("%d %s %d",num_Period_T,name_Date_T,year_T);
}
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]; 
}
最后一个提供数据 10. zac 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