View Code of Problem 2592

#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	getchar();
	while(t--){
		char c;
		int x;
		cin>>c>>x;
		getchar();
		if(x==0){
			continue;
	   }
	   else if(x==1)
	   {
	   	cout<<c<<endl;
	   }else{
		for(int i=1;i<x;i++){
			cout<<" ";
		}
		cout<<c<<endl;
		for(int i=2;i<=x-1;i++){
			for(int k=1;k<=x-i;k++)
			cout<<" ";
			cout<<c;
			for(int k=1;k<=2*(i-1)-1;k++)
			cout<<" ";
			cout<<c<<endl;
		}
		for(int i=1;i<2*x;i++)
		cout<<c;
		cout<<endl;
	   }
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 2592