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