Hello all. This is my first post in this forum and I hope I won't sound like a complete idiot.
I need a little hint for this number pattern problem I have here. I have to print the following pattern -:
So far I've gotten the left side numbers and the underscores right, but I just can't think of how to get the right side numbers. My code looks something like this -:
1 2 3 4 5 6 7 8 9
int i, j, k;
for(i = 1; i <= 4; i++)
{
for(j = 1; j <= i; j++)
cout << i;
for(k = 1; k <= 2*4 - i; k++)
cout << "_";
cout << endl;
}
I thought of doing the right side numbers by the concept of a right-lower triangular matrix, but I can't get that right either. Then I thought of starting i from the maximum value and decrementing thereon but that would screw up everything else. What do I do, senors?
(Note : Spaces between underscores and numbers are only shown for clarity)