Java-POJ1008-Maya Calendar

Posted Jason-Cow

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java-POJ1008-Maya Calendar相关的知识,希望对你有一定的参考价值。

题意:两种纪年方法的转换

水题,根据题目翻译成代码就可以了

居然WA了一次,避坑,output要先输出数据组数,痛心疾首啊!本来可以一次AC的。

 1 package poj.ProblemSet;
 2 
 3 import java.util.Scanner;
 4 
 5 public class poj1008 {
 6     public static final String[] Tzolkin_day = {"", "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
 7 
 8     public static int Month(String month) {
 9         if (month.equals("pop")) return 0;
10         if (month.equals("no")) return 1;
11         if (month.equals("zip")) return 2;
12         if (month.equals("zotz")) return 3;
13         if (month.equals("tzec")) return 4;
14         if (month.equals("xul")) return 5;
15         if (month.equals("yoxkin")) return 6;
16         if (month.equals("mol")) return 7;
17         if (month.equals("chen")) return 8;
18         if (month.equals("yax")) return 9;
19         if (month.equals("zac")) return 10;
20         if (month.equals("ceh")) return 11;
21         if (month.equals("mac")) return 12;
22         if (month.equals("kankin")) return 13;
23         if (month.equals("muan")) return 14;
24         if (month.equals("pax")) return 15;
25         if (month.equals("koyab")) return 16;
26         if (month.equals("cumhu")) return 17;
27         return 18;//if(month=="uayet")
28     }
29     public static void main(String[] args) {
30         Scanner cin = new Scanner(System.in);
31         int n = cin.nextInt();
32         System.out.println(n);
33         for (int i = 1; i <= n; i++) {
34             int day = (int) cin.nextDouble();
35             String month = cin.next();
36             int year = cin.nextInt();
37             int x = (year * 365 + Month(month) * 20 + day);
38             int a = x % 13 + 1;
39             String b = Tzolkin_day[x % 20 + 1];
40             int c = (int) x / (13 * 20);
41             System.out.println(a + " " + b + " " + c);
42         }
43     }
44 }

 

以上是关于Java-POJ1008-Maya Calendar的主要内容,如果未能解决你的问题,请参考以下文章

[POJ] POJ1008 Maya Calendar

poj1008Maya Calendar

POJ 1008 Maya Calendar

[POJ] #1008# Maya Calendar : 字符处理/同余问题

Java-POJ1003-Hangover

Java-POJ1012-Joseph