title: How can I generate the following pattern using C++?
body: <p>If  n = 5</p>
  <pre><code>1   2   1   5
  2   4   3   4
  3   6   5   3
  4   8   7   2
  5   10  9   1
  </code></pre>
  <p>I have tried the following code but doesn't give the correct output.</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  void main()
  {
      int i, j;
      for (i = 1; i &lt;= 5; i++) {
          for (j = 1; j &gt;= i; j++) {
              cout &lt;&lt; j;
              j += 2;
          }
          cout &lt;&lt; endl;
      }
  }
  </code></pre>
  <p>Can someone please correct this  code</p>