Witam,
prosibym o pomoc aby wskazac mi co robie zle w kodzie Java skoro zwraca mi blad:
Blad wykonania (NZEC)
KOD:
package posz;
import java.io.IOException;
import java.util.Scanner;
public class Main {
/**
* @param args the command line arguments
* @throws java.lang.Exception
*/
public static void main(String[] args)throws java.lang.Exception {
// TODO code application logic here
try{
Scanner in = new Scanner(System.in);
short i;
int j;
short D = (short) in.nextInt();
DataSet[] allData = new DataSet[D];
for(i=0;i<D;i++)
{
allData[i]= new DataSet();
int N = in.nextInt();
for(j=0;j<N;j++)
{
short dir=(short) in.nextInt();
short steps = (short) in.nextInt();
allData[i].addStep(dir,steps);
}
}
for(i=0;i<D;i++)
{
allData[i].printRoute();
}
System.gc();
}catch (Exception e)
{
return;
}
}
}
class DataSet
{
long NS=0;
long EW=0;
public DataSet()
{
this.NS=0;
this.EW=0;
}
public void addStep(short dir, short steps)
{
switch(dir)
{
case 0:
this.NS+=(long) steps;
break;
case 1:
this.NS-=(long) steps;
break;
case 2:
this.EW-=(long) steps;
break;
case 3:
this.EW+=(long) steps;
break;
}
}
public void printRoute()
{
if(this.NS==0 && this.EW==0)
{
System.out.println("studnia");
}else{
String message="";
if(this.NS>0) message+="0 " + String.valueOf(this.NS) ;
if (this.NS<0) message+="1 " + String.valueOf(Math.abs(this.NS)) ;
System.out.println(message);
message="";
if(this.EW>0) message+="3 " + String.valueOf(this.EW) ;
if (this.EW<0) message+="2 " + String.valueOf(Math.abs(this.EW)) ;
System.out.println(message);
}
}
}