#include <iostream>
void print_row( int row_num, int num_total_rows ) // first row is row #1
{
constint num_asterisks = row_num*2 - 1 ;
constint num_underscores = num_total_rows - row_num ;
// first print the underscores
for( int i = 0 ; i < num_underscores ; ++i ) std::cout << '_' ;
// then print the asterisks
for( int i = 0 ; i < num_asterisks ; ++i ) std::cout << '*' ;
std::cout << '\n' ; // and finally a new line
}
int main()
{
int nrows = 15 ;
// ...
// print the rows [1 ... nrows ] one by one
for( int r = 1 ; r <= nrows ; ++r ) print_row( r, nrows ) ;
}