title: Java two-dimensional array filled with pattern
body: <p>how can I fill two-dimensional array of given "size" to get this output:<br>
  N=1  </p>
  
  <blockquote>
    <p>000<br>
       010<br>
       000</p>
  </blockquote>
  
  <p>N=2</p>
  
  <blockquote>
    <p>0000<br>
       0110<br>
       0110<br>
       0000  </p>
  </blockquote>
  
  <p>N=3</p>
  
  <blockquote>
    <p>00000<br>
       01110<br>
       01210<br>
       01110<br>
       00000  </p>
  </blockquote>
  
  <pre><code>public static void main (String[] args) throws java.lang.Exception
  {
      int x, y;
      int N = 3;
      int counter = 0;
      x = y = N + 2;
      int[][] array = new int[x][y];
      for( int i = 0; i&lt;x; i++){
          for( int j = 0; j &lt; y; j++){
              if( i == 0 || i == x-1 || j == 0 || j == y-1){
                  array[i][j] = 0;
              } else {
                  array[i][j] = 1;
              }
              System.out.print(array[i][j]);
          }
          System.out.println();
      }
  }
  </code></pre>
  
  <p>This code gives me just 1s surrounded by 0, but I cannot figure out how to increase value to the middle of array. If N is an odd number I can use modulo, but i don't know how to do this with even numbers.</p>