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. int a=1;
  10. int nsc=n-1;
  11. int nsp=1;
  12.  
  13. for(int r=1;r<=2*n-1;r++)
  14. printf("%d",a);
  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. a++;
  22.  
  23. for(int k=1;k<=nsp;k++)
  24. printf(" ");
  25. a++;
  26.  
  27. for(int x=1;x<=nsc;x++)
  28. printf("%d",a);
  29. a++;
  30.  
  31. nsc--;
  32. nsp+=2;
  33.  
  34. printf("\n");
  35.  
  36. }
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
stdout
Enter the number of rows: 
111111111
1234 3333
123   666
12     99
1       12