View Code of Problem 53

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	int k=2*n-1;
	int a[k][k];
	int i,j;
	for(i=0;i<n;i++)
	{
		int x=n-i-1;
		int y=k-2*x;
		for(j=0;j<x+y;j++)
		{
			if(j<x)
				printf(" ");
			else
				printf("*");
		}
		printf("\n");
	}
	for(i=n;i<k;i++)
	{
		int x=i+1-n;
		int y=k-2*x;
		for(j=0;j<x+y;j++)
		{
			if(j<x)
				printf(" ");
			else
				printf("*");
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 53