123456789101112131415161718192021222324252627282930
#include<iostream> using namespace std; int main() { int row; int col; int numRows; int numCols; char chr; cout << "enter num rows: "; cin >> numRows; cout << "enter num cols: "; cin >> numCols; cout << "enter char: "; cin >> chr; for (row = 1; row <= numRows; row++) { for (col = 1; col <= numCols; col++) { if (col <= row) { cout << chr; } } cout << endl; } }
12345678
if (col <= numRows - row) { cout << ' '; } else { cout << chr; }