View Code of Problem 2592

#include<stdio.h>
#include<string.h>
int main(){
	int t;
	scanf("%d",&t);
	getchar();
	while(t--){
	char s;
	int a;
	int i,j,k;
	scanf("%c %d",&s,&a);
	getchar();
		for(j=1;j<=a;j++){//输出每个三角形的格式 
				for(k=a-j;k>0;k--) printf(" ");
			if(j==1){
				printf("%c\n",s);		
			} 
			else if(j>1&&j<a){
				int m;
				printf("%c",s);
				for(m=2*(j-1)-1;m>0;m--) printf(" ");
				printf("%c\n",s);
			} 
			else if(j==a){
				int n=2*a-1;
				while(n--){
					printf("%c",s);
				}
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 2592