View Code of Problem 57

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

Double click to view unformatted code.


Back to problem 57