View Code of Problem 57

#include<stdio.h>
#include<string.h>
int main(){
	char a[100],c;
	int i,len,k,j=0,s[100],f1,f2,s1,s2,m1,m2,x,y;
	scanf("%d",&k);
	for(i=1;i<=k;i++){
		for(j=i;j<k;j++){
			printf("%c",' ');
		}
		for(j=1;j<=i;j++){
			printf("%d",j);
		}
		for(j=i-1;j>=1;j--){
			printf("%d",j);
		}
		printf("\n");
	}
	for(i=k-1;i>=1;i--){
		for(j=i;j<k;j++){
			printf("%c",' ');
		}
		for(j=1;j<=i;j++){
			printf("%d",j);
		}
		for(j=i-1;j>=1;j--){
			printf("%d",j);
		}
		printf("\n");
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 57