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 pclion2008 at 2010-05-25 13:17:49 on Problem 1008
#include <iostream>
using namespace std;

const char inp[3][16] = {"10. zac 0", "0. pop 0", "10. zac 1995"};
char HaabMonths[19][8] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
char TzolkinDay[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" };

int HaabMonth2Index(char *m)
{
	for(int i=0;i<19;i++)
		if (strcmp(m, HaabMonths[i])==0) return i;
	return -1;
}

int fromHaab(int d, char* m, int y)
{
	int n = HaabMonth2Index(m);
	if (n == -1) return -1;
	return 365*y + 20*n + d;
}

void toTzolkin(int haab, int& d, char** m, int& y)
{
	y = haab / 260;
	int n = haab % 260;
	d = (n % 13) + 1;
	*m = TzolkinDay[n % 20];
}

struct Haab {
	int d;
	char m[16];
	int y;
};

struct Tzolkin {
	int d;
	char m[16];
	int y;
};

int main()
{   
	int d,y;  
	char m[16];
	char *pm;
	int n;
	scanf("%d",&n);
	if (n<=0) exit(1);

	cout << n << endl;

	for(int i=0;i<n;i++) {
		scanf("%d. %s %d", &d,m, &y);  
		if (y>=5000) exit(1);
		int h = fromHaab(d,m,y);
		if (h==-1) cout <<"wrong\n";
		else {
			toTzolkin(h,d,&pm,y);
			cout << d <<" " << pm <<" "<< y << endl;   
		}
	}

	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