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

## Re:奇妙的runtime error了，求达人指点

Posted by 737363395 at 2014-09-18 00:34:01 on Problem 1330
In Reply To:奇妙的runtime error了，求达人指点 Posted by:834208094 at 2012-05-12 00:34:48
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.util.ArrayList;
> import java.util.Scanner;
>
> public class Main {
>
> 	public static void getFather(ArrayList Father, ArrayList Child, int child, ArrayList FATHERS) {
>  		int index = Child.indexOf(child + "");
> 		while(index >= 0) {
> 			index = Child.indexOf(Father.get(index));
> 		}
> 	}
>
> 	public static void main(String args[]) {
> 		Scanner sc = new Scanner(System.in);
> 		String s = sc.nextLine();
> 		int firstline = Integer.parseInt(s);
> 		for(int i=0; i<firstline; i++) {
> 			ArrayList al1 = new ArrayList();
> 			ArrayList al2 = new ArrayList();
> 			ArrayList al3 = new ArrayList();
> 			ArrayList al4 = new ArrayList();
> 			String S = sc.nextLine();
> 			int secondline = Integer.parseInt(S);
> 			for(int k=0; k<secondline-1; k++) {
> 				String lines = sc.nextLine();
> 			}
> 			String string = sc.nextLine();
> 			getFather(al1, al2, Integer.parseInt((string.split(" ")[0])), al3);
> 			getFather(al1, al2, Integer.parseInt((string.split(" ")[1])), al4);
> 			outer:
> 			for(int I=0; I<al3.size(); I++) {
> 				for(int K=0; K<al4.size(); K++) {
> 					int numal3 =  Integer.parseInt((String)al3.get(I));
> 					int numal4 =   Integer.parseInt(((String)al4.get(K)));
> 					if(numal3 == numal4) {
> 						System.out.println(al3.get(I));
> 						break outer;
> 					}
> 				}
> 			}
> 		}
> 	}
> }

Followed by: