fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int n,i,j,k;
  6.  
  7. printf("Enter any odd number:");
  8. scanf("%d",&n);
  9. k=(n+1)/2;
  10. k--;
  11.  
  12. if(n%2==0 || n==0 || n<0)
  13. {
  14. printf("Wrong input!");
  15. }
  16.  
  17. else
  18. {
  19. for(i=0;i<=(n+k);i++)
  20. {
  21. printf("\n");
  22. for(j=1;j<=(n+1)/2;j++)
  23. {
  24. printf("%d",i);
  25. }
  26. if(i<(n+1)/2)
  27. {
  28. for(j=0;j<n;j++)
  29. {
  30. printf(" ");
  31. }
  32. for(j=0;j<i;j++)
  33. {
  34. printf("@");
  35. }
  36. }
  37. else
  38. {
  39. printf("*");
  40. if(i==(n+1)/2)
  41. {
  42. for(j=1;j<n;j++)
  43. {
  44. printf("*");
  45.  
  46. }
  47. for(j=1;j<=i;j++)
  48. {
  49. printf("@");
  50. }
  51. }
  52. else
  53. {
  54. for(j=1;j<n;j++)
  55. {
  56. printf(" ");
  57. }
  58. }
  59.  
  60. }
  61. }
  62.  
  63. for(i=0;i<n;i++)
  64. {
  65. printf("\n");
  66. for(j=0;j<(n+2);j++)
  67. {
  68. printf("*");
  69. }
  70. }
  71. }
  72. return 0;
  73. }
  74.  
Success #stdin #stdout 0s 4484KB
stdin
5
stdout
Enter any odd number:
000     
111     @
222     @@
333*****@@@
444*    
555*    
666*    
777*    
*******
*******
*******
*******
*******