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程序测试数据都过了,为什么还是Runtime Error?下面是代码import java.util.Scanner; import java.util.StringTokenizer; public class Maya { static int iNumber1 = 1, iNumber2, iNumber3; public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); iNumber1 = scan.nextInt(); String[] string = new String[iNumber1]; for (iNumber3 = 0; iNumber3 < iNumber1; iNumber3++) { Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); iNumber2 = convert1(str); string[iNumber3] = convert2(iNumber2); } System.out.println(iNumber1); for(iNumber3=0;iNumber3<iNumber1;iNumber3++) System.out.println(string[iNumber3]); } public static int convert1(String str){ int iNumber1 = 0,iNumber2,iNumber3; String[] string = new String[3]; StringTokenizer st = new StringTokenizer(str,". "); while(st.hasMoreTokens()){ string[iNumber1] = st.nextToken(); iNumber1++; } iNumber2 = Integer.parseInt(string[2]); iNumber3 = Integer.parseInt(string[0]); if(string[1].equals("uayet")) iNumber2 = iNumber2*365+iNumber3+1+20*18; else if(string[1].equals("pop")) iNumber2 = iNumber2*365+iNumber3+1+20*0; else if(string[1].equals("no")) iNumber2 = iNumber2*365+iNumber3+1+20*1; else if(string[1].equals("zip")) iNumber2 = iNumber2*365+iNumber3+1+20*2; else if(string[1].equals("zotz")) iNumber2 = iNumber2*365+iNumber3+1+20*3; else if(string[1].equals("tzec")) iNumber2 = iNumber2*365+iNumber3+1+20*4; else if(string[1].equals("xul")) iNumber2 = iNumber2*365+iNumber3+1+20*5; else if(string[1].equals("yoxkin")) iNumber2 = iNumber2*365+iNumber3+1+20*6; else if(string[1].equals("mol")) iNumber2 = iNumber2*365+iNumber3+1+20*7; else if(string[1].equals("chen")) iNumber2 = iNumber2*365+iNumber3+1+20*8; else if(string[1].equals("yax")) iNumber2 = iNumber2*365+iNumber3+1+20*9; else if(string[1].equals("zac")) iNumber2 = iNumber2*365+iNumber3+1+20*10; else if(string[1].equals("ceh")) iNumber2 = iNumber2*365+iNumber3+1+20*11; else if(string[1].equals("mac")) iNumber2 = iNumber2*365+iNumber3+1+20*12; else if(string[1].equals("kankin")) iNumber2 = iNumber2*365+iNumber3+1+20*13; else if(string[1].equals("muan")) iNumber2 = iNumber2*365+iNumber3+1+20*14; else if(string[1].equals("pax")) iNumber2 = iNumber2*365+iNumber3+1+20*15; else if(string[1].equals("koyab")) iNumber2 = iNumber2*365+iNumber3+1+20*16; else if(string[1].equals("cumhu")) iNumber2 = iNumber2*365+iNumber3+1+20*17; return iNumber2; } public static String convert2(int iNumber){ int iNumbera,iNumberb,iNumberc; String str = null; iNumbera = iNumber/260; iNumberb = iNumber%260; iNumberc = iNumberb%13; iNumberb = iNumberb%20; if(iNumberc == 0) iNumberc = 13; if(iNumberb == 0) iNumbera = iNumbera - 1; switch(iNumberb){ case 1:str = "imix"; break; case 2:str = "ik"; break; case 3:str = "akbal"; break; case 4:str = "kan"; break; case 5:str = "chicchan"; break; case 6:str = "cimi"; break; case 7:str = "manik"; break; case 8:str = "lamat"; break; case 9:str = "muluk"; break; case 10:str = "ok"; break; case 11:str = "chuen"; break; case 12:str = "eb"; break; case 13:str = "ben"; break; case 14:str = "ix"; break; case 15:str = "mem"; break; case 16:str = "cib"; break; case 17:str = "caban"; break; case 18:str = "eznab"; break; case 19:str = "canac"; break; case 0:str = "ahau"; break; } return (iNumberc+" "+str+" "+iNumbera); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator