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 511304198911080419 at 2008-12-28 00:40:24 on Problem 1008
#include"stdio.h"
#include "malloc.h"
#include "string.h"
#include "stdlib.h"
#define compare(a) if (strcmp(a,month)==0)
#define cmpr(c,b) if(c==b)
int input(char *all,char *day,char *month,char *year);
void copy(char *from,char *to);
int analyse1(char *day,char *month,char *year);
void main()
{
	int num;
	int i;
	char **Total;
	char **day;
	char **month;
	char **Tzo_month;
	char **year;
	int DaySum;
	int i_day;
	int i_year;
	int i_month;
	int left;
	char* str;
	scanf("%d",&num);
	getchar();
	Tzo_month=(char **)malloc(10*num);
	Total=(char **)malloc(10*num);
	day=(char **)malloc(10*num);
	month=(char **)malloc(10*num);
	year=(char **)malloc(10*num);
	for (i=0;i<num;i++)
	{
		
		Tzo_month[i]=(char *)malloc(90);
		Total[i]=(char *)malloc(200);
		day[i]=(char *)malloc(30);
		month[i]=(char*)malloc(60);
		year[i]=(char*)malloc(60);
		gets(Total[i]);
		input(Total[i],day[i],month[i],year[i]);
	}
	printf("%d\n",num);
	for (i=0;i<num;i++)
	{
		DaySum=analyse1(day[i],month[i],year[i]);
		i_year=DaySum/260;
		left=DaySum%260;
		i_day=left%13+1;
		i_month=left%20;
		{
			cmpr(i_month,0)
				str="imix";
			cmpr(i_month,1)
				str="ik";
			cmpr(i_month,2)
				str="akbal";
			cmpr(i_month,3)
				str="kan";
			cmpr(i_month,4)
				str="chicchan";
			cmpr(i_month,5)
				str="cimi";
			cmpr(i_month,6)
				str="manik";
			cmpr(i_month,7)
				str="lamat";
			cmpr(i_month,8)
				str="muluk";
			cmpr(i_month,9)
				str="ok";
			cmpr(i_month,10)
				str="chuen";
			cmpr(i_month,11)
				str="eb";
			cmpr(i_month,12)
				str="ben";
			cmpr(i_month,13)
				str="ix";
			cmpr(i_month,14)
				str="mem";
			cmpr(i_month,15)
				str="cib";
			cmpr(i_month,16)
				str="caban";
			cmpr(i_month,17)
				str="eznab";
			cmpr(i_month,18)
				str="canac";
			cmpr(i_month,19)
				str="ahau";
			copy(str,Tzo_month[i]);
		}
		printf("%d %s %d\n",i_day,Tzo_month[i],i_year);
	}
	for (i=0;i<num;i++)
	{
		free(Tzo_month[i]);
		Tzo_month[i]=NULL;
		free(Total[i]);
		Total[i]=NULL;
		free(day[i]);
		day[i]=NULL;
		free(month[i]);
		month[i]=NULL;
		free(year[i]);
		year[i]=NULL;
	}
	free(Tzo_month);
	Tzo_month=NULL;
	free(Total);
	Total=NULL;
	free(day);
	day=NULL;
	free(month);
	month=NULL;
	free(year);
	year=NULL;
}
int input(char *all,char *day,char *month,char *year)

{
	int i;
	int j;
	int k;
	for (i=0;all[i]!='.';i++)
	{
		day[i]=all[i];
	}
	day[i]=0;
	for (j=i+2;all[j]!=' ';j++)
	{
		month[j-i-2]=all[j];
	}
	month[j-i-2]=0;
	for (k=j+1;all[k]!=0;k++)
	{
		year[k-j-1]=all[k];
	}
	year[k-j-1]=0;
	return 0;
}
int analyse1(char *day,char *month,char *year)
{
	int i_sum;
	int i_month;
	int i_day=atoi(day);
	int i_year=atoi(year);
	compare("pop")
		i_month=1;
	compare("no")
		i_month=2;
	compare("zip")
		i_month=3;
	compare("zotz")
		i_month=4;
	if(strcmp("tzec",month)==0)
		i_month=5;
	if(strcmp("xul",month)==0)
		i_month=6;
	if(strcmp("yoxkin",month)==0)
		i_month=7;
	if(strcmp("mol",month)==0)
		i_month=8;
	if(strcmp("chen",month)==0)
		i_month=9;
	if(strcmp("yax",month)==0)
		i_month=10;
	compare("zac")
		i_month=11;
	compare("ceh")
		i_month=12;
	compare("mac")
		i_month=13;
	compare("kankin")
		i_month=14;
	compare("muan")
		i_month=15;
	compare("pax")
		i_month=16;
	compare("koyab")
		i_month=17;
	compare("cumku")
		i_month=18;
	compare("uayet")
		i_month=19;
	i_sum=i_year*365+(i_month-1)*20+i_day;
	return(i_sum);
}
void copy(char *from,char *to)
{
	int i;
	for (i=0;from[i]!=0;i++)
	{
		to[i]=from[i];
	}
	to[i]=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