View Code of Problem 2592

#include<stdio.h>
int main(){
	int t,i,j;
	scanf("%d",&t);
	getchar();
	while(t--){
		char c;
		int n;
		scanf("%c %d",&c,&n);
		getchar();
		for(i=1;i<=n;i++){
			for(j=n-i;j>=1;j--){
				printf(" ");
			}
			if(i==1||i==n){
				for(j=1;j<=2*i-1;j++){
					printf("%c",c);
				}
			}
			else{
				printf("%c",c);
				for(j=0;j<2*i-3;j++){
					printf(" "); 
				}
				printf("%c",c);
			}
			printf("\n");
		}
	}
	
}

Double click to view unformatted code.


Back to problem 2592