fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. printf("Enter the number: \n");
  6. scanf("%d",&n);
  7.  
  8.  
  9.  
  10. for(int i=1;i<=n;i++){
  11.  
  12. for(int sp=1;sp<=n-i;sp++){
  13. printf(" ");
  14. }
  15. int a=1;
  16. for(int j=1;j<=i;j++){
  17. printf(" %d ",a);
  18. a++;
  19. }
  20.  
  21. int b=i-1;
  22. for(int k=1;k<=i-1;k++){
  23. printf(" %d ",b);
  24. b--;
  25. }
  26.  
  27. printf("\n");
  28. }
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5320KB
stdin
7
stdout
Enter the number: 
                   1 
                1  2  1 
             1  2  3  2  1 
          1  2  3  4  3  2  1 
       1  2  3  4  5  4  3  2  1 
    1  2  3  4  5  6  5  4  3  2  1 
 1  2  3  4  5  6  7  6  5  4  3  2  1