View Code of Problem 57

#include<stdio.h>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
      int n;
      scanf("%d", &n);
	  for(int i=-(n-1);i<n;i++){
	  	for(int j=0;j<abs(i);j++){
	  		printf(" ");
		  }
		  int m=(2*(n-abs(i)))-1;
		  int a=1,l;
		  for(int k=0;k<m;k++){
		  	
		  	if(a<=n-abs(i)){
		  		l=a-1;
		  		printf("%d",a);
		  		a++;
			  }
		  	
		  	else{
		  			printf("%d",l);
		  			l--;
			  }
		  	
			  
		  	
		  }
		  printf("\n");
	  }
       
	  return 0;
}

Double click to view unformatted code.


Back to problem 57