View Code of Problem 2592

#include<iostream>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		char f;
		int x;
		cin>>f;
		cin>>x;
		for(int i=0;i<x;i++){
			for(int j=0;j<x-i-1;j++){
				cout<<' ';
			}
			if(i==0){
				cout<<f;
			}
			else if(i==x-1){
				for(int i=0;i<2*(x-1)+1;i++){
					cout<<f;
				}
			}
			else{
				cout<<f;
				for(int j=0;j<2*i-1;j++){
					cout<<' ';
				}
				cout<<f;
			}
			cout<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 2592