Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- int main()
- {
- int linha, coluna, c1, c2, quantmov, contador, li, ci;
- scanf("%i %i", &linha, &coluna);
- int matriz[linha][coluna];
- for(c1 = 0 ; c1 < linha ; ++c1)
- {
- for (c2 = 0; c2 < coluna ; ++c2)
- {
- scanf("%i", &matriz[linha][coluna]);
- }
- }
- scanf("%i", &quantmov);
- quantmov - 1;
- int mov[quantmov];
- char movimento;
- contador = quantmov;
- while (contador >= 0)
- {
- scanf("%c", &movimento);
- printf("%c", movimento);
- if(movimento == 'C')
- {
- mov[contador] = 1;
- }
- if(movimento == 'D')
- {
- mov[contador] = 2;
- }
- if(movimento == 'B')
- {
- mov[contador] = 3;
- }
- if(movimento == 'E')
- {
- mov[contador] = 4;
- }
- --contador;
- }
- scanf("%i%i", &li, &ci);
- contador = quantmov;
- while (contador >= 0)
- {
- if(mov[contador] == 1 && matriz[li + 1][ci] == 1)
- {
- li+=1;
- }
- else if(mov[contador] == 2 && matriz[li][ci + 1] == 1)
- {
- ci += 1;
- }
- else if(mov[contador] == 3 && matriz[li - 1][ci] == 1)
- {
- li -= 1;
- }
- else if(mov[contador] == 4 && matriz[li][ci - 1] == 1)
- {
- ci -= 1;
- }
- --contador;
- }
- printf("(%i,%i)\n", ci, li);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement