title: Turning several loops into one recursion
body: <p>I have this piece of code: </p>
  
  <pre><code>for (int i=0; i&lt;N; i++)
  {
      int j;
      if (i%2==1) j=1;
      else j=0;
      for (; j&lt;N; j+=2)
      {
          for(int k=0; k&lt;N; k++)
          {
              int n;
              if (k%2==1) n=1;
              else n=0;
              for (; n&lt;N; n+=2)
              {
  
                  for (int l=0; l&lt;N; l++)
                  {
                      int o;
                      if (l%2==1) o=1;
                      else o=0;
                      for (; o&lt;N; o+=2)
                      {
  
                          for(int m=0; m&lt;N; m++)
                          {
                              int p;
                              if (m%2==1) p=1;
                              else p=0;
                              for (; p&lt;N; p+=2)
                              {
  
                                  if (check_full(lenta,i,j,k,n,l,o,m,p))
                                  {
                                      count++;
                                      cout&lt;&lt;"Lenta uzsipilde: ("&lt;&lt;i&lt;&lt;","&lt;&lt;j&lt;&lt;"), "&lt;&lt;"("&lt;&lt;k&lt;&lt;","&lt;&lt;n&lt;&lt;"), "&lt;&lt;"("&lt;&lt;l&lt;&lt;","&lt;&lt;o&lt;&lt;"), "&lt;&lt;"("&lt;&lt;m&lt;&lt;","&lt;&lt;p&lt;&lt;"), "&lt;&lt;endl;
                                  }
  
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Is there any way it could be turned into recursion? Basically these loops find all possible coordinates for given problem. And if it can be converted into one small recursion, will I need to use array instead of 8 variables?</p>
  
  <p>Here's what I tried to do, but it doesn't work: </p>
  
  <pre><code>void findBishops(){
      for (int i=0; i&lt;N; i++){
          int j;
          if (i%2==1) j=1; 
          for (; j&lt;N; j+=2){
              putIntoArray(array, i, j);
              if (isFull(board, array)){
                  PrintAnswer(array);
              }else{
                  arrayCount = arrayCount-2;
                  findBishops();
              }
              }
      }
      }
  void putIntoArray(array[], i, j){
      array[arrayCount++] = i;
      array[arrayCount++] = j;
  }
  </code></pre>