*题目大意*:
日历转换
*解题思路*:
将日历转换为与世界起始天的相差天数即可。
注意%和/的使用, 输入输出的处理。
*代码*:
<textarea readonly="readonly" name="code" class="c++">
#include <iostream>
#include <cstdio>
using namespace std;
int hday, hyear, hmonth, tday, tmonth, tyear;
char hstr[10];
int total;
char tstr[20][30] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban",
"eznab", "canac", "ahau"};
void str_to_num(char s[])
{
switch(s[0])
{
case 'p': if (s[1]=='o') hmonth = 1;
if (s[1]=='a') hmonth = 16;
break;
case 'n': hmonth = 2; break;
case 'z': if (s[1]=='i') hmonth = 3;
if (s[1]=='o') hmonth = 4;
if (s[1]=='a') hmonth = 11;
break;
case 't': hmonth = 5; break;
case 'x': hmonth = 6; break;
case 'y': if (s[1]=='o') hmonth = 7;
if (s[1]=='a') hmonth = 10;
break;
case 'm': if (s[1]=='o') hmonth = 8;
if (s[1]=='a') hmonth = 13;
if (s[1]=='u') hmonth = 15;
break;
case 'c': if (s[1]=='h') hmonth = 9;
if (s[1]=='e') hmonth = 12;
if (s[1]=='u') hmonth = 18;
break;
case 'k': if (s[1]=='a') hmonth = 14;
if (s[1]=='o') hmonth = 17;
break;
case 'u': hmonth = 19;break;
}
}
int main()
{
// freopen("1.txt","r", stdin);
int t;
scanf("%d", &t);
printf("%d\n", t);
while (t--)
{
scanf("%d.%s%d", &hday, hstr, &hyear);
str_to_num(hstr);
total = 365*hyear+(hday)+(hmonth-1)*20;
tyear = total / 260;
tmonth = (total % 260) % 13+1;
tday = (total%260)%20;
printf("%d %s %d\n", tmonth, tstr[tday], tyear);
}
return 0;
}
</textarea>