GastonFontenla

Untitled

May 29th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. bool esValido(int i, int j, int alto, int ancho)
  7. {
  8.     return (0 <= i && i < alto && 0 <= j && j < ancho);
  9. }
  10.  
  11. int x[] = {-1, 0, 1, -1, 1, -1, 0, 1};
  12. int y[] = {1, 1, 1, 0, 0, -1, -1, -1};
  13.  
  14. void recorrerMatrizYCheckearAdyacentes(vector<vector <char> > m)
  15. {
  16.     for(int i=0; i<m.size(); i++)
  17.     {
  18.         for(int j=0; j<m[i].size(); j++)
  19.         {
  20.             int contadorAst = 0;
  21.             for(int k=0; k<8; k++)
  22.             {
  23.                 int dx = i+x[k];
  24.                 int dy = j+y[k];
  25.                 if(esValido(dx, dy, m.size(), m[i].size()))
  26.                 {
  27.                     ///Hago algo en la posición dx, dy
  28.                 }
  29.             }
  30.         }
  31.     }
  32. }
  33.  
  34. int main()
  35. {
  36.     cout << "Hello world!" << endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment