Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "labirinto.h"
- #include <iostream>
- using namespace std;
- int matriz[7][13]={
- {1,1,1,0,1,1,0,0,0,1,1,1,1}
- ,{1,0,1,1,1,0,1,1,1,1,1,0,1}
- ,{1,0,0,0,1,0,1,0,1,0,1,0,1}
- ,{1,0,0,0,1,1,1,0,1,0,1,1,1}
- ,{1,1,1,1,1,0,0,0,0,1,0,0,0}
- ,{0,0,0,0,1,0,0,0,0,0,0,0,0}
- ,{0,0,0,0,1,1,1,1,1,1,1,1,1}};
- void mover(int x,int y);
- int main( int argc, const char* argv[] ){
- mover(0,0);
- for(int i=0;i<7;i++){
- for(int j =0;j<13;j++){
- cout<<matriz[i][j];
- }
- cout<<endl;
- }
- system("PAUSE");
- }
- void mover(int x,int y){
- if(x==6 && y==12) return;
- if(x-1 >= 0 && matriz[x-1][y]!=9 && matriz[x-1][y]!=0){//CIMA
- matriz[x][y]=9;
- mover(x-1,y);
- }
- if(y+1 <13 && matriz[x][y+1]!=9 && matriz[x][y+1]!=0){//DIREITA
- matriz[x][y]=9;
- mover(x,y+1);
- }
- if(x+1 < 7 && matriz[x+1][y]!=9 && matriz[x+1][y]!=0){//BAIXO
- matriz[x][y]=9;
- mover(x+1,y);
- }
- if(y-1 >= 0 && matriz[x][y-1]!=9 && matriz[x][y-1]!=0){//Esquerda
- matriz[x][y]=9;
- mover(x,y-1);
- }
- }
Add Comment
Please, Sign In to add comment