View Code of Problem 2592

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int t;
    char c;
    int n;
    cin >> t;
    while (t--)
    {
        getchar();
        cin >> c >> n;
        for (int i = 0; i < n; i++)
        {
            for (int j = 1; j < n - i; j++)
                cout << " ";
            cout << c;
            for (int j = 0; j < 2 * (i - 1) + 1; j++)
                if (i < n - 1)
                    cout << " ";
                else
                    cout << c;
            if (i != 0)
                cout << c;
            cout << endl;
        }
    }
}

Double click to view unformatted code.


Back to problem 2592