Go to diff to previous submission
#include <stdio.h> int Pole[201][201]; int FrontaX[100*100*20]; int FrontaY[100*100*20]; int Zac,Kon; int R,C,Gr,Gc,Lr,Lc,Cc,Cr,T; int Found; void Skoc(int X, int Y, int Time) { //printf("> %d %d %d\n",X,Y,Time); if ((X<1) || (X>R) || (Y<1) || (Y>C)) return; if ((Pole[X][Y] > Time) || (Pole[X][Y] == -1)) { Pole[X][Y]=Time; FrontaX[++Kon]=X; FrontaY[Kon]=Y; if ((X == Lr) && (Y == Lc)) Found = 1; }; }; int main() { int x,y; for (x=0;x<=R;x++) for (y=0;y<=C;y++) Pole[x][y]=-1; if ((Gr==Lr) && (Gc == Lc)) { } else { FrontaX[0]=Gr; FrontaY[0]=Gc; Zac=0; Kon=0; Found=0; Pole[Gr][Gc]=0; while ((Zac<=Kon) && (Found==0)) { Cr = FrontaX[Zac]; Cc = FrontaY[Zac++]; T = Pole[Cc][Cr]; //printf("%d %d %d %d %d\n",Cc,Cr,T,Zac,Kon); Skoc(Cr+2,Cc+1,T+1); Skoc(Cr+2,Cc-1,T+1); Skoc(Cr-2,Cc+1,T+1); Skoc(Cr-2,Cc-1,T+1); Skoc(Cr+1,Cc+2,T+1); Skoc(Cr+1,Cc-2,T+1); Skoc(Cr-1,Cc+2,T+1); Skoc(Cr-1,Cc-2,T+1); }; if (Pole[Lr][Lc] == -1) { } else { }; }; }; return 0; };
--- c4.s620.cteam048.grasshop.c.0.grasshop.c +++ c4.s622.cteam048.grasshop.c.0.grasshop.c @@ -35,6 +35,6 @@ Pole[Gr][Gc]=0; while ((Zac<=Kon) && (Found==0)) { - Cc = FrontaX[Zac]; - Cr = FrontaY[Zac++]; + Cr = FrontaX[Zac]; + Cc = FrontaY[Zac++]; T = Pole[Cc][Cr]; //printf("%d %d %d %d %d\n",Cc,Cr,T,Zac,Kon);