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

c++能过,g++不能,wa。。。

Posted by 2008011292 at 2010-02-07 13:52:50 on Problem 1008
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int Haab (char* cm) {
	if (!strcmp (cm, "pop"))
		return 1;
	if (!strcmp (cm, "no"))
		return 2;
	if (!strcmp (cm, "zip"))
		return 3;
	if (!strcmp (cm, "zotz"))
		return 4;
	if (!strcmp (cm, "tzec"))
		return 5;
	if (!strcmp (cm, "xul"))
		return 6;
	if (!strcmp (cm, "yoxkin"))
		return 7;
	if (!strcmp (cm, "mol"))
		return 8;
	if (!strcmp (cm, "chen"))
		return 9;
	if (!strcmp (cm, "yax"))
		return 10;
	if (!strcmp (cm, "zac"))
		return 11;
	if (!strcmp (cm, "ceh"))
		return 12;
	if (!strcmp (cm, "mac"))
		return 13;
	if (!strcmp (cm, "kankin"))
		return 14;
	if (!strcmp (cm, "muan"))
		return 15;
	if (!strcmp (cm, "pax"))
		return 16;
	if (!strcmp (cm, "koyab"))
		return 17;
	if (!strcmp (cm, "cumhu"))
		return 18;
	if (!strcmp (cm, "uayet"))
		return 19;
	return 0;
}

char* Tzolkin (int m) {
	char a[21][14] = {"", "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk",
		"ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
	return a[m];
}

int main() {
	int n, d1, m1, y1, d, m, y;
	char cm1[9], cm[14];
	unsigned long count;
	cin >> n;
	if (n)
		cout << n << endl;
	while (n--) {
		count = 0;
		cin >> d1;
		getchar();
		cin >> cm1 >> y1;
		m1 = Haab (cm1);
		count += 365 * y1;
		count += d1 + 1;
		count += 20 * (m1 - 1);
		y = (count - 1) / 260;
		count -= y * 260;
		d = count % 13;
		if (!d)
			d = 13;
		m = count % 20;
		if (!m)
			m = 20;
		strcpy (cm, Tzolkin (m));
		cout << d << " " << cm << " " << 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