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

一直是runtime error

Posted by dailyye at 2008-04-11 21:35:18 on Problem 1002
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main{

	/**
	 * @param args
	 */

	public static void main(String[] args)throws NumberFormatException { 
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int num[]=new int[10000000];
		if(n>100000)n=100000;
		for (int i = 0; i < n; i++) {
			String sNumber = cin.next();
			sNumber = sNumber.replace("A", "2");
			sNumber = sNumber.replace("B", "2");
			sNumber = sNumber.replace("C", "2");
			sNumber = sNumber.replace("D", "3");
			sNumber = sNumber.replace("E", "3");
			sNumber = sNumber.replace("F", "3");
			sNumber = sNumber.replace("G", "4");
			sNumber = sNumber.replace("H", "4");
			sNumber = sNumber.replace("I", "4");
			sNumber = sNumber.replace("J", "5");
			sNumber = sNumber.replace("K", "5");
			sNumber = sNumber.replace("L", "5");
			sNumber = sNumber.replace("M", "6");
			sNumber = sNumber.replace("N", "6");
			sNumber = sNumber.replace("O", "6");
			sNumber = sNumber.replace("P", "7");
			sNumber = sNumber.replace("R", "7");
			sNumber = sNumber.replace("S", "7");
			sNumber = sNumber.replace("T", "8");
			sNumber = sNumber.replace("U", "8");
			sNumber = sNumber.replace("V", "8");
			sNumber = sNumber.replace("W", "9");
			sNumber = sNumber.replace("X", "9");
			sNumber = sNumber.replace("Y", "9");
			sNumber = sNumber.replace("-", "");
			
			 
				try {
				int iNumber = Integer.parseInt(sNumber);
				System.out.println(iNumber);
				num[iNumber]++;
			} catch (Exception e) {
			}
			 
		}
		int temp=0;
		for(int i=0;i<num.length;i++)
			
		{
			if(num[i]>1)
			{
				String s=new Integer(i).toString();
				System.out.println(s.charAt(0)+""+s.charAt(1)+s.charAt(2)+"-"+s.charAt(3)+s.charAt(4)+s.charAt(5)+s.charAt(6)+" "+num[i]);
			temp=1;
			}
			
		}
		if(temp==0) 
		{
			System.out.println("No duplicates.");
		}
		 
	}
}
 

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