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 llz6662034 at 2011-04-18 20:12:36 on Problem 1008
#include <stdio.h>
#include <string.h>
#include <math.h> 
int main()
{
	int times;
	char a[100]={0};
	char x[100];
	int year[1000]={0},date[1000]={0},month[1000]={0},i=0,j=0,all=0,l=0;
	int year1[1000],date1[1000],month1[1000],k=0,m=1,n=0;
	void exchange(int *p,char *q,int i);
	void put(int a,int b,int c);
	scanf("%d",&times);
	getchar();
	while(j<times)
	{
		gets(x);
		if(x[3]==32)
		{
			date[j]=(x[0]-48)*10+x[1]-48;
			for(k=4,i=0;x[k]!=32;k++)
			{
				a[i]=x[k];
				i++;
			}
		}
		else
		{
			date[j]=x[0]-48;
			for(k=3,i=0;x[k]!=32;k++)
			{
				a[i]=x[k];
				i++;
			}
		}
		for(m=k+1;x[m]!=0;m++);
		for(i=m-k-1,n=0;i>0;i--,n++,m--)
		{
			year[j]=(x[m-1]-48)*(int)pow(10.,n)+year[j];
		}
		exchange(month,a,j);
		j++;
	}
	while(j>0)
	{
		l=times-j;
		j--;
		if(month[l]<18)
			all=year[l]*365+month[l]*20+date[l]+1;
		else
			all=year[l]*365+360+date[l]+1;
		if(all%260!=0)
		{
			year1[l]=all/260;
			date1[l]=(all-year1[l]*260)%13;
			month1[l]=(all-year1[l]*260)%20;
		}
		else
		{
			year1[l]=all/260-1;
			date1[l]=13;
			month1[l]=20;		
		}
		if(j==times-1)
			printf("%d\n",times);
		put(date1[l],month1[l],year1[l]);
	}
	return 0;
}
void exchange(int *p,char *q,int i)
{
	if(strcmp(q,"pop")==0)
		p[i]=0;
	if(strcmp(q,"no")==0)
		p[i]=1;
	if(strcmp(q,"zip")==0)
		p[i]=2;
	if(strcmp(q,"zotz")==0)
		p[i]=3;
	if(strcmp(q,"tzec")==0)
		p[i]=4;
	if(strcmp(q,"xul")==0)
		p[i]=5;
	if(strcmp(q,"yoxkin")==0)
		p[i]=6;
	if(strcmp(q,"mol")==0)
		p[i]=7;
	if(strcmp(q,"chen")==0)
		p[i]=8;
	if(strcmp(q,"yax")==0)
		p[i]=9;
	if(strcmp(q,"zac")==0)
		p[i]=10;
	if(strcmp(q,"ceh")==0)
		p[i]=11;
	if(strcmp(q,"mac")==0)
		p[i]=12;
	if(strcmp(q,"kankin")==0)
		p[i]=13;
	if(strcmp(q,"muan")==0)
		p[i]=14;
	if(strcmp(q,"pax")==0)
		p[i]=15;
	if(strcmp(q,"koyab")==0)
		p[i]=16;
	if(strcmp(q,"cumhu")==0)
		p[i]=17;
	if(strcmp(q,"uayet")==0)
		p[i]=18;
}
void put(int a,int b,int c)
{
	printf("%d ",a);
	switch(b)
	{
	case 1:printf("imix");break;
	case 2:printf("ik");break;
	case 3:printf("akbal");break;
	case 4:printf("kan");break;
	case 5:printf(" chicchan");break;
	case 6:printf("cimi");break;
	case 7:printf("manik");break;
	case 8:printf("lamat");break;
	case 9:printf("muluk");break;
	case 10:printf("ok");break;
	case 11:printf("chuen");break;
	case 12:printf("eb");break;
	case 13:printf("ben");break;
	case 14:printf("ix");break;
	case 15:printf("mem");break;
	case 16:printf("cib");break;
	case 17:printf("caban");break;
	case 18:printf("eznab");break;
	case 19:printf("canac");break;
	case 20:printf("ahau");break;
	}
	printf(" %d\n",c);
}

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