Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我用java写了一段代码,不知道哪里错了,显示wrong answer.求大神指教。import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext()){ List<Integer> list = new ArrayList<Integer>(); int n = cin.nextInt(); for (int i = 0; i < n; i++) { int totalDays = 0; String day = cin.next(); String month = cin.next(); day = day.substring(0, day.lastIndexOf('.')); int year = cin.nextInt(); int monthnum = 0; int daynum = 0; monthnum = monthChange(month); daynum = Integer.parseInt(day); totalDays = year * 365 + monthnum * 20 + daynum + 1; list.add(totalDays); } System.out.println(n); Iterator it = list.iterator(); while (it.hasNext()) { int res=(Integer) it.next(); int TzolkinYear=res/260; int TzolkinMonth=(res)%13; if(TzolkinMonth==0){TzolkinMonth=13;} int TzolkinDays=(res)%20; if(TzolkinDays==0){TzolkinDays=20;} String TzolkinDayString=dayChange(TzolkinDays-1); System.out.println(TzolkinMonth+" "+TzolkinDayString+" "+TzolkinYear); } } } public static int monthChange(String word) { String wholeMonth = "pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu ,uayet"; String[] monthArray = wholeMonth.split(","); int num = 0; for (int x = 0; x < 19; x++) { if (monthArray[x].contains(word)) { num = x; } } return num; } public static String dayChange(int day) { String wholeDays="imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau"; String []days=wholeDays.split(","); String res=""; for(int i=0;i<20;i++) { if(i==day) res=days[i];} return res; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator