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++)// first line
  14.  
  15. printf("%d",r);
  16. printf("\n");
  17.  
  18. for(int i=1;i<=n;i++){
  19. int a=1;
  20. for(int j=1;j<=nsc;j++)
  21. printf("%d",a);
  22. a++;
  23.  
  24. for(int k=1;k<=nsp;k++)
  25. printf(" ");
  26. a++;
  27.  
  28. for(int x=1;x<=nsc;x++)
  29. printf("%d",a);
  30. a++;
  31.  
  32. nsc--;
  33. nsp+=2;
  34.  
  35. printf("\n");
  36.  
  37. }
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 5316KB
stdin
5
stdout
Enter the number of rows: 
123456789
1111 3333
111   333
11     33
1       3