fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;// 12345
  5. // 12 45
  6. // 1 5
  7. printf("Enter the number of rows: \n");
  8. scanf("%d",&n);
  9.  
  10. int nsc=n-1;
  11. int nsp=1;
  12.  
  13. for(int r=1;r<=2*n-1;r++)
  14. printf("%d",r);
  15. printf("\n");
  16.  
  17. for(int i=1;i<=n;i++){
  18.  
  19. for(int j=1;j<=nsc;j++)
  20. printf("%d",j);
  21.  
  22. for(int k=1;k<=nsp;k++)
  23. printf(" ");
  24.  
  25. for(int x=2*n-1;x>n+1;x--)
  26. printf("%d",x);
  27.  
  28. nsc--;
  29. nsp+=2;
  30.  
  31. printf("\n");
  32.  
  33. }
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5316KB
stdin
5
stdout
Enter the number of rows: 
123456789
1234 987
123   987
12     987
1       987
         987