fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int x, i, j, space;
  7.  
  8. scanf("Enter an odd number:%d", &x);
  9. space = x-1;
  10.  
  11. for ( j = 1 ; j <= x ; j++ )
  12. {
  13. for ( i = 1 ; i <= space ; i++ )
  14. printf(" ");
  15. space--;
  16. for ( i = 1 ; i <= j ; i++ )
  17. printf("%2d", i);
  18. for ( i-=2 ; i >=1 ; i-- )
  19. printf("%2d", i);
  20. printf("\n");
  21. }
  22.  
  23. space = 1;
  24. for ( j=1 ; j <= x-1 ; j++ )
  25. {
  26. for ( i = 1 ; i <= space; i++ )
  27. printf(" ");
  28. space++;
  29. for ( i = 1 ; i <= x-j ; i++ )
  30. printf("%2d", i);
  31. for ( i-=2 ; i >=1 ; i-- )
  32. printf("%2d", i);
  33. printf("\n");
  34. }
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5284KB
stdin
5
stdout
Standard output is empty