title: How to print a diamond pattern using only two loops?
body: <p>Could anyone tell me how to modify my code.</p>
  
  <p>I want to print a diamond pattern using only two loops.
  If I enter 5, the diamond should be like this:</p>
  
  <pre><code>  *  
   *** 
  *****
   *** 
    *  
  </code></pre>
  
  <p>I am half way  done.</p>
  
  <p>here is what I got so far.</p>
  
  <pre><code>  5
    *  
   *** 
  *****
   ****
    ***
  </code></pre>
  
  <p>Below is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  // print diamond. Instead of finding * pattern, just find "  " 's pattern.
  int main()
  {
      int size;
      cin &gt;&gt; size;
      int m = size / 2;
  
      for (int row = 0; row &lt; size; row++) {
          for (int col = 0; col &lt; size; col++) { //   Before || is the left part. After || is right part
              if ((row &lt; m &amp;&amp; (col &lt; m - row || col &gt; m + row)) || (row &gt; m &amp;&amp; col &lt; row - m))
                  cout &lt;&lt; " ";
  
              else
                  cout &lt;&lt; "*";
          }
          cout &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>