码迷,mamicode.com
首页 > 编程语言 > 详细

Java-POJ1008-Maya Calendar

时间:2020-01-27 23:58:53      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:ems   font   stat   strong   void   int()   poj   pop   ann   

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

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

居然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

标签:ems   font   stat   strong   void   int()   poj   pop   ann   

原文地址:https://www.cnblogs.com/JasonCow/p/12237035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!