Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么运行时异常,不能看报错信息啊啊啊啊啊啊啊啊

Posted by yangdaren at 2019-11-26 16:30:06 on Problem 1008 and last updated at 2019-11-26 16:37:57
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //日月年看着真变扭
        //首先把 H 日期 转天数,
        //然后把天数 转 T 日期
        List<String> list = new ArrayList<String>();
        String[] hDateMonthDefine = "pop,no,zip,zotz,tzec,xul,yoxkin,mol,chen,yax,zac,ceh,mac,kankin,muan,pax,koyab,cumhu".split(",");
        String[] tDateDayDefine = "imix,ik,akbal,kan,chicchan,cimi,manik,lamat,muluk,ok,chuen,eb,ben,ix,mem,cib,caban,eznab,canac,ahau".split(",");
        Scanner scanner = new Scanner(System.in);
        int rows = scanner.nextInt(), daysCount = 0, hDateMonth2Int = 0, length, tDateYear, tDateDayNumber;
        String hDate, hDateDay, hDateMonth, hDateYear, tDateDayWord;
        StringBuilder tDate = new StringBuilder();
        String[] hDateSplitArray;
        scanner.nextLine();
        for (int i = 0; i < rows; i++) {
            //读取一行,空格分隔符,年数乘以365,月数乘以20,再加天数,数组下标应该是 0,1,2
            hDate = scanner.nextLine();
            hDateSplitArray = hDate.split(" ");
            //天数去掉末尾的点"."
            length = hDateSplitArray[0].length();
            hDateDay = hDateSplitArray[0].substring(0, length - 1);
            hDateMonth = hDateSplitArray[1];
            hDateYear = hDateSplitArray[2];
            //天数是 0 开始算的。
            daysCount += Integer.valueOf(hDateDay) + 1;
            daysCount += Integer.valueOf(hDateYear) * 365;
            //计算月数,遍历月份数组,比较相等得到,下标等于要的月数
            for (int j = 0; j < hDateMonthDefine.length; j++) {
                if (hDateMonth.equals(hDateMonthDefine[j])) {
                    hDateMonth2Int = j;
                }
            }
            //加上月数乘以20
            daysCount += hDateMonth2Int * 20;
            //把天数转为 T 日期,输出
            //天数除以 260 等于年数,没有月份,要求当天的名字。。。数字和单词。。
            tDateYear = daysCount / 260;
            //除以年数后的余数,对 13 取余等于天的数字,对 20 取余 等于 天单词的数组下标+1,要-1 才是天单词的下标 第一天的下标是 0
            tDateDayNumber = daysCount % 260 % 13;
            int tDateDayDefineIndex = daysCount % 260 % 20;
            tDateDayWord = tDateDayDefine[tDateDayDefineIndex - 1];
            //拼接
            tDate.append(tDateDayNumber);
            tDate.append(" ");
            tDate.append(tDateDayWord);
            tDate.append(" ");
            tDate.append(tDateYear);
            list.add(tDate.toString());
            length = tDate.length();
            tDate.delete(0, length);
            daysCount = 0;
        }
        //输出
        System.out.println(rows);
        for (String aList : list) {
            System.out.println(aList);
        }
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator