View Code of Problem 57

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

Double click to view unformatted code.


Back to problem 57