Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define SIZE 7
- int position_x, position_y;
- int x,y;
- int tablica[SIZE][SIZE] = {{0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 1, 1, 1, 1, 1, 1, 0 },
- { 0, 1, 0, 0, 0, 0, 0, 0 },
- { 0, 1, 0, 1, 1, 1, 1, 1 },
- { 0, 1, 0, 1, 0, 0, 0, 0 },
- { 0, 1, 0, 1, 2, 1, 1, 0 },
- { 0, 1, 0, 1, 1, 1, 1, 0 },
- { 8, 1, 0, 0, 0, 0, 0, 0 }};
- int stos[10];
- gora();
- dol();
- prawo();
- lewo();
- int gora(int position_y, int tablica)
- {
- if (position_y + 1 == 0 && position_y + 1 <= SIZE)
- {
- return 1;
- }
- else
- return 0;
- }
- int dol(int position_y, int tablica)
- {
- if (position_y - 1 == 0 && position_y - 1 <= SIZE)
- {
- return 1;
- }
- else
- return 0;
- }
- int lewo (int position_x, int tablica)
- {
- if (position_x + 1 == 0 && position_x + 1 <= SIZE)
- {
- return 1;
- }
- else
- return 0;
- }
- int prawo (int position_x, int tablica)
- {
- if (position_x - 1 == 0 && position_x - 1 <= SIZE)
- {
- return 1;
- }
- else
- return 0;
- }
- int main()
- {
- position_x = 0;
- position_y = 7;
- while ( tablica[position_x][position_y]!= 2)
- {
- if (gora(position_y, tablica));
- {
- position_y = position_y + 1;
- elseif(dol(position_y, tablica));
- {
- position_y = position_y - 1;
- elseif(lewo(position_x, tablica));
- {
- position_x = position_x - 1;
- elseif(prawo(position_x, tablica));
- {
- position_x = position_x + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement