I'm guessing you are asking for help in printing out a triangle like this:
1 2 3 4 5 6
*
**
***
****
*****
******
using a 'for' loop. But whether you meant that shape or not, this should be posted in the General C++ section, rather than the lounge. The lounge is for off-topic topics. :D I don't know if you can move this or not, I've never tried before. But if you can get it there, I'm sure someone would be glad to help.
Also, try to use full sentences, proper grammar, and correct spelling to the best of your ability (if english isn't your first language, mistakes are understandable). That will certainly improve the amount people are willing to help you, because it will appear that you are grateful for their time and efforts.
Oh! I remember my first time doing that! I had the one like Numeri then I had to change it, I used space character and deducted the number then adding the *
eg
25 spaces *
23 spaces ***
Till it filed up to the bottom. ☺ hope that helps
though there is a mathematical way, It was my simplest way while learning Accelerate C++
hey
I did that before and it requires a nested for loop. The outter main loop is the lines the triangle takes up. The second loop contains the asterisks(*) and the inner look contains spaces (' ') .
example for the triangle above:
for (int i = 5; i>0; i--)
{
for(int j = 0; j< i-1; j++)
cout<<' ';
for(int k = i; k<= 5; k++)
cout<<'*';
cout<<endl;
}
}
It's probably easiest to do that way though, although a recursive solution may be even more elegant (at the cost of performance due to function call overhead and the risk of a stack overflow if you try to recurse too many times).