Go to diff to previous submission
import java.util.Scanner; /** * * @author cteam060 */ public class Main { /** * @param args the command line arguments */ int i,z,j,k,i1,i2,j1,j2; boolean skok = false; int tah[][] = new int[9][2]; tah[8][0]=1; tah[8][1]=2; tah[1][0]=2; tah[1][1]=1; tah[2][0]=2; tah[2][1]=-1; tah[3][0]=1; tah[3][1]=-2; tah[4][0]=-1; tah[4][1]=-2; tah[5][0]=-2; tah[5][1]=-1; tah[6][0]=-2; tah[6][1]=1; tah[7][0]=-1; tah[7][1]=2; while(sc.hasNext()){ int r = sc.nextInt(); int c = sc.nextInt(); int gr = sc.nextInt(); int gc = sc.nextInt(); int lr = sc.nextInt(); int lc = sc.nextInt(); int sach[][]= new int[c+1][r+1]; for(i=1;i<=c;i++){ for(j=1;j<=r;j++){ sach[i][j]=-1; } } sach[gc][gr]=0; int krok=1; while(sach[lr][lc]==-1){ skok = false; for(i1=1;i1<=c;i1++){ for(i2=1;i2<=r;i2++){ if(sach[i1][i2]==krok-1){ for(k=1;k<=8;k++){ j1=i1+tah[k][0]; j2=i2+tah[k][1]; if((j2>0)&&(j2<r+1)&&(j1>0)&&(j1<c+1)){ if(sach[j1][j2]==-1){ sach[j1][j2]=krok; skok = true; } } } } } } krok++; if(!skok){break;} } else { } } } }
--- c4.s768.cteam060.grasshop.java.0.Grasshop.java +++ c4.s776.cteam060.grasshop.java.0.Grasshop.java @@ -41,12 +41,12 @@ } } - //ok + sach[gc][gr]=0; int krok=1; while(sach[lr][lc]==-1){ skok = false; - for(i1=1;i1<=c;i1++){ //procházíme pole a pokud je krok-1 tak zněj zkoušíme skákat + for(i1=1;i1<=c;i1++){ for(i2=1;i2<=r;i2++){ - if(sach[i1][i2]==krok-1){ // + if(sach[i1][i2]==krok-1){ for(k=1;k<=8;k++){