地址:http://poj.org/problem?id=1008
一开始不知道自己为啥一直Runtime Error,后面发现自己眼睛瞎了,少写一种情况…
#include "pch.h"
#include<string>
#include <iostream>
using namespace std;
int sl3;
string sl1;
string sl2;
int Haab(string s2)
{
if (s2 == "pop")
return 0;else if (s2 == "no")
return 1 * 20;else if (s2 == "zip")
return 2 * 20;else if (s2 == "zotz")
return 3 * 20;else if (s2 == "tzec")
return 4 * 20;else if (s2 == "xul")
return 5 * 20;else if (s2 == "yoxkin")
return 6 * 20;else if (s2 == "mol")
return 7 * 20;else if (s2 == "chen")
return 8 * 20;else if (s2 == "yax")
return 9 * 20;else if (s2 == "zac")
return 10 * 20;else if (s2 == "ceh")
return 11 * 20;else if (s2 == "mac")
return 12 * 20;else if (s2 == "kankin")
return 13 * 20;else if (s2 == "muan")
return 14 * 20;else if (s2 == "pax")
return 15 * 20;else if (s2 == "koyab")
return 16 * 20;else if (s2 == "cumhu")
return 17 * 20;else
return 18 * 20;
}
string Tzolkin(int day)
{
switch (day)
{
case 1:return "imix";case 2:return "ik";
case 3:return "akbal";case 4:return "kan";
case 5:return "chicchan";case 6:return "cimi";
case 7:return "manik";case 8:return "lamat";
case 9:return "muluk";case 10:return "ok";
case 11:return "chuen";case 12:return "eb";
case 14:return "ix";case 15:return "mem";
case 16:return "cib";case 17:return "caban";
case 18:return "eznab";case 19:return "canac";
case 20:return "ahau";case 13:return "ben";
}
}
void map(int date)
{
int day, number, year;
string Day;
year = date / 260;
number = (date - year * 260) % 13+1;
day = (date - year * 260) % 20+1;
Day = Tzolkin(day);
cout << number << " " << Day << " " << year << endl;
}
void Hash()
{
int day = 0, k;
day = atoi(sl1.c_str());
k = Haab(sl2);
day += k + sl3 * 365;
map(day);
}
int main()
{
int n; cin >> n;
cout << n << endl;
for (int i = 0; i < n; i++)
{
cin >> sl1 >> sl2 >> sl3;
Hash();
}
return 0;
}