View Code of Problem 57

#include<string.h>
#include<stdio.h>
#include<math.h>
int main(){
	int i,n,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=i;j<n;j++){
			printf(" ");
		}
		for(j=1;j<i+1;j++){	
			printf("%d",j);	
		}
		for(j=i-1;j>0;j--){
			printf("%d",j);	
		}
		printf("\n");
	}
	for(i=n-1;i>0;i--){
		for(j=i;j<n;j++){
			printf(" ");
		}
		for(j=1;j<i+1;j++){	
			printf("%d",j);	
		}
		for(j=i-1;j>0;j--){
			printf("%d",j);	
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 57