View Code of Problem 2592

#include <bits/stdc++.h>
using namespace std;
int main(){

    int t;
    cin>>t;
    
    while(t--){
        char s;
        int n;
        cin>>s>>n;
        char a[101][101];
        for(int i = 0; i<101; i++){
            for(int j = 0; j<101; j++){
                a[i][j] =' ';
            }
        }
        a[0][n-1] = s;
        for(int i = 1 ; i<n-1 ;i++){
            a[i][n-i-1] = s;
            a[i][n+i-1] = s;
        }
        for(int i = 0; i<n*2-1; i++){
            a[n-1][i]  = s;
        }
        int cnt = n;
        for(int i = 0; i<n; i++){
            for(int j =0 ; j<cnt; j++){
                cout<<a[i][j];
            }
            cnt++;
            cout<<endl;
        }

    }
   return 0;
}

Double click to view unformatted code.


Back to problem 2592