>dear use function
Dear, don't suggest nonportable functions unless you know that they're supported and acceptable solutions.
>I AM ONLY ABLE TO ALIGN THE TRIANGLES VERTICALLY AND NOT HORIZONTALLY
For each row, handle all of the triangles rather than just one:
#include <iostream>
using namespace std;
int main()
{
for ( int r = 0; r < 10; r++ ) {
// Ascending
for ( int i = 0; i < 10; i++ )
cout.put ( i <= r ? '*' : ' ' );
cout.put ( ' ' );
// Descending
for ( int i = 9; i >= 0; i-- )
cout.put ( i >= r ? '*' : ' ' );
cout<<endl;
}
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401