Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int ruch(int tab[12][12], int pozx, int pozy, int licznik)
- {
- tab[pozx][pozy]=licznik;
- printf("%d ",licznik);
- if(tab[pozx+2][pozy+1]==0){return ruch(tab,pozx+2,pozy+1,licznik+1);}
- else
- {
- if(tab[pozx+2][pozy-1]==0){return ruch(tab,pozx+2,pozy-1,licznik+1);}
- else
- {
- if(tab[pozx+1][pozy+2]==0){return ruch(tab,pozx+1,pozy+2,licznik+1); }
- else
- {
- if(tab[pozx+1][pozy-2]==0){return ruch(tab,pozx+1,pozy-2,licznik+1);}
- else
- {
- if(tab[pozx-2][pozy+1]==0){return ruch(tab,pozx-2,pozy+1,licznik+1);}
- else
- {
- if(tab[pozx-2][pozy-1]==0){return ruch(tab,pozx-2,pozy-1,licznik+1);}
- else
- {
- if(tab[pozx-1][pozy+2]==0){return ruch(tab,pozx-1,pozy+2,licznik+1);}
- else
- {
- if(tab[pozx-1][pozy-2]==0){return ruch(tab,pozx-1,pozy-2,licznik+1);}
- else
- {
- if(licznik==64) //nie weszlem
- {
- for(int i=2;i<10;i++)
- { printf("\n");
- for(int j=2;j<10;j++)
- {
- printf("%4d",tab[i][j]);
- }
- }
- }else
- {printf("\nczemu nie potrafi zawrocic?!");
- tab[pozx][pozy] = 0;
- return 0;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- int main()
- {
- int tab[12][12];
- for(int i=0;i<12;i++)
- {
- for(int j=0;j<12;j++)
- {
- tab[i][j] = 1;
- }
- }
- for(int i=2; i<10; i++)
- {
- for(int j=2; j<10; j++)
- {
- tab[i][j] = 0;
- }
- }
- printf("\n%d",ruch(tab,2,2,1));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement