poj1008

package easy;


import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 *poj1008 考英语理解能力
 * @author NC
 */
public class Poj1008 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        String[] monthName = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
            "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"};
        String[] dayName = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik",
            "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban",
            "eznab", "canac", "ahau"};
        if (scan.hasNext()) {
            int n = Integer.parseInt(scan.nextLine().trim());
            String[] result = new String[n];
            for (int i = 0; i < n; i++) {
                String s = scan.nextLine();
                String[] ss = s.trim().split(" ");
                int day1 = Integer.parseInt(ss[0].substring(0, ss[0].length() - 1));
                String month1 = ss[1];
                int year1 = Integer.parseInt(ss[2]);
                int days = 0;
                int k = 0;
                for (k = 0; k < monthName.length; k++) {
                    if (month1.equals(monthName[k])) {
                        break;//找出第几个月这里比较巧妙
                    }
                }
                days = 365 * year1 + 20 * k + day1;//如果是uayet,刚k=18
                result[i] = (days % 260 % 13 + 1) + " " + dayName[days % 260 % 20] + " " + days / 260;
            }
            System.out.println(n);
            for (int i = 0; i < n; i++) {
                System.out.println(result[i]);
            }
        }
    }
}

你可能感兴趣的:(poj)