Anyone Nid help with this :(

I need to make a C++ program whose output should be like this

_____1
____232
___34543
__4567654
_567898765

using nested loop

just out of idea xD
Last edited on
Though this is not the best solution but it works.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <iomanip>

int main()
{
   const int N = 6;

   for ( int i = 1; i < N; i++ )
   {
      int k = 2 * i - 1;

      std::cout << std::setw( N + 1 - i );

      for ( int j = i; j < i + k; j++ )
      {
         if ( j > k ) std::cout << 2 * k - j;
         else std::cout << j;
      }

      std::cout << std::endl;
   }

   return ( 0 );
}
thx a lot this will do :)
Topic archived. No new replies allowed.