TEMA
Problema Runtime error
dmedeiros3 preguntado 6 years ago
Quando envio da Runtime error. Não consegui achar o erro, alguém poderia ajudar ?
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int test = scan.nextInt();
while(test != 0) {
int p = 0;
test--;
int instruc = scan.nextInt();
Integer[] reserva = new Integer[instruc+1];
for(int i = 1; i <= instruc; i++) {
String comando = br.readLine();
if (comando.equalsIgnoreCase("LEFT")) {
p--;
reserva[i] = -1;
}else if (comando.equals("RIGHT")) {
p++;
reserva[i] = 1;
}else {
int u = Integer.parseInt(comando.substring(8));
p = p + (reserva[u]);
reserva[i] = reserva[u];
}
}
System.out.println(p);
}
}