title: Creates A Number Pattern Using Array
body: <p>So the numbers pattern going like this :</p>
  
  <hr>
  
  <pre><code>Input    : 2
  Output   : 
              0  0  0  1  0   0  0
              0  0  2  0  12  0  0
              0  3  0  0  0   11 0
              4  0  0  0  0   0  10
              0  5  0  0  0   9  0
              0  0  6  0  8   0  0
              0  0  0  7  0   0  0
  </code></pre>
  
  <p>I have solved it using usual method, but when I tried with array, the output is really messed up. Any suggestion how to make this number pattern with array?</p>
  
  <p>This is my code that creates this number pattern : </p>
  
  <pre><code>int input, n, mid, i, j;
  cin &gt;&gt; input;
  
  n = (2*input)+3;
  mid = (n+1)/2;
  
  for(i = 1; i &lt;= n; i++) {
      for (j = 1; j &lt;= mid; j++) {
          if (i &lt;= mid &amp;&amp; j == mid-i+1) cout &lt;&lt; i &lt;&lt; " ";
          else if (i &gt; mid &amp;&amp; j == mid-n+i) cout &lt;&lt; i &lt;&lt; " ";
          else cout &lt;&lt; "0 ";
      }
      for (j = mid+1; j &lt;= n; j++) {
          if (i &gt;= mid &amp;&amp; j == n+mid-i) cout &lt;&lt; (2*n-i) &lt;&lt; " ";
          else if (i &lt; mid &amp;&amp; j == mid+i-1) cout &lt;&lt; (2*n-i) &lt;&lt; " ";
          else cout &lt;&lt; "0 ";
      }
      cout &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>