View Code of Problem 53

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

Double click to view unformatted code.


Back to problem 53