title: Printing triangle of numbers in C++ in a specific way?
body: <p>I have a program where I have to print triangle of numbers in a specific way. My program prints for example for 5 the following:</p>
  
  <pre><code>1
  1 2
  1 2 3
  1 2 3 4
  1 2 3 4 5
  </code></pre>
  
  <p>I want to print them the following way:</p>
  
  <pre><code>         1
         1 2
       1 2 3
     1 2 3 4
   1 2 3 4 5
  </code></pre>
  
  <p>I tried with setw() using the iomanip library but it did not work. My question is  how can I fix that.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int n,br=1;
  int main()
  {
      cin&gt;&gt;n;
      while (br&lt;=n)
      {
          for(int i=1; i&lt;=br; i++)
          {
  
              cout&lt;&lt;i&lt;&lt;' ';
          }
          br++;
          cout&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>