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