Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #define VEL 50
- void tiskniDalsiPoziceKone(int x, int y, bool navstiveno[VEL][VEL]) {
- if (x >= 0 && y >= 0 && x < VEL && y < VEL && !navstiveno[x][y]) {
- navstiveno[x][y] = true;
- printf("%d, %d\n", x, y);
- tiskniDalsiPoziceKone(x - 1, y - 2, navstiveno);
- tiskniDalsiPoziceKone(x + 1, y - 2, navstiveno);
- tiskniDalsiPoziceKone(x - 1, y + 2, navstiveno);
- tiskniDalsiPoziceKone(x + 1, y + 2, navstiveno);
- tiskniDalsiPoziceKone(x - 2, y + 1, navstiveno);
- tiskniDalsiPoziceKone(x + 2, y + 1, navstiveno);
- tiskniDalsiPoziceKone(x - 2, y - 1, navstiveno);
- tiskniDalsiPoziceKone(x + 2, y - 1, navstiveno);
- }
- }
- int main() {
- bool pole[VEL][VEL];
- for (int i = 0; i < VEL; i++)
- for (int j = 0; j < VEL; j++) pole[i][j] = false;
- tiskniDalsiPoziceKone(4, 3, pole);
- for (int i = 0; i < VEL; i++) {
- for (int j = 0; j < VEL; j++)
- if (pole[i][j]) printf("X");
- else printf(".");
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement