View Code of Problem 2592

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define inf 0x7fffffff

int main() {
	int t;
	scanf("%d",&t);
	while(t--){
		char ch;
		int n;
		getchar();
		scanf("%c %d",&ch,&n);
		for(int i=1;i<n;i++){
			for(int j=1;j<=n-i;j++){
				printf(" ");
			}
			for(int j=1;j<=2*i-1;j++){
				if(j==1||j==2*i-1){
					printf("%c",ch);
				}else{
					printf(" ");
				}
			}
			printf("\n");
		}
		for(int i=1;i<=2*n-1;i++){
			printf("%c",ch);
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 2592