View Code of Problem 2592

#include<stdio.h>

int main()
{
	char str;
	int n,i,j,k;
	while(scanf("%c%d",&str,&n)!=EOF)
	{
		for(j=1;j<=n-1;j++)	printf(" ");
		printf("%c\n",str);
		for(i=2;i<=n-1;i++)
		{
			for(j=1;j<=n-i;j++)	printf(" ");
			printf("%c",str);
			for(j=1;j<=2*i-3;j++)	printf(" ");
			printf("%c\n",str);
		}
		if(n!=1)
		{
			for(j=1;j<=2*n-1;j++)	printf("%c",str);
			printf("\n");
		}
		getchar();
	}
}

Double click to view unformatted code.


Back to problem 2592