java rutime error on test 1

Правка en1, от soumiaMoufid, 2017-02-05 01:44:18

please i got "rutime error on test 1" with this code any help?? thanks in advance

package graph.party;

import java.util.ArrayList;
import java.util.Scanner;

public class Party2 {

	public Party2() {
		Scanner in = new Scanner(System.in);
		System.out.println("entrez le nombre des employés\n");
		int n = in.nextInt();
		ArrayList<Integer> tab=new ArrayList<Integer>(n);
		for(int i=0;i<n;i++){
			tab.add(in.nextInt());
		}
		int result=0;
		for(int j=0;j<n;j++){
			int temp=1;int var=tab.get(j);
			while(var != -1){var=tab.get(var-1);temp++;}
			if(temp>result) result=temp;
		}
		System.out.println(result);
	}

	public static void main(String[] args) {
		new Party2();

	}

}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский soumiaMoufid 2017-02-05 01:44:18 762 Initial revision (published)