View Code of Problem 57

#include <stdio.h>
int main(){
  	int i,j,n,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=n-i;j++)
			printf(" ");
		for(k=1;k<=2*i-1;k++)
		{
			if(k<=i)
				printf("%d",k);
			else
				printf("%d",2*i-k);
		}
		printf("\n");

	}
	for(i=1;i<=n-1;i++){
		for(j=1;j<=i;j++)
			printf(" ");
		for(k=1;k<=2*(n-i)-1;k++)
		{	if(k<=n-i)
				printf("%d",k);
			else
				printf("%d",2*(n-i)-k);
			
		}
		printf("\n");

	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 57