Advertisement
akanoce

Labyrinth

Apr 18th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. //PRE_t=(N ha m*m elementi definiti)
  2. bool trova(bool *N,int m, int i, int j){
  3.    
  4.  
  5.    if(i!= m-1){
  6.        cout<<"Riga "<<i<<" Colonna "<<j<<endl;
  7.        
  8.    if(*(N+m-1) == 1 && j!=0)
  9.             return trova(N+m-1,m,i+1,j-1);
  10.            
  11.     if(*(N+m) == 1)
  12.             return trova(N+m,m,i+1,j);
  13.            
  14.     if(*(N+m+1) == 1 && j!=m-1)
  15.             return trova(N+m+1,m,i+1,j+1);
  16.         else
  17.             return false;
  18.        
  19.    
  20.    }//Finchè non sono all'ultima riga
  21.    else
  22.    return true;
  23.    
  24.    
  25. }//trova
  26. //POST=(restituisce true se in N vista come X[m][m] c’è un cammino da (I,j) alla riga m-1 composto da sole caselle bianche)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement