Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. int main()
  2. {
  3. int height,k,i,j,row=1,z=1,sum,hashtag;
  4. scanf("%d", &height);
  5. k=height;
  6. if ( height <= 2 ) {
  7. sum = 0;
  8. } else
  9. {
  10.  
  11. hashtag = 1;
  12. sum = 1;
  13. for ( i = 1; i < height - 2; i++)
  14. {
  15. hashtag = hashtag + 2;
  16. sum = sum + hashtag;
  17. }
  18. }
  19. printf("%d\n", sum);
  20. for(i=0;i<k-1;i++)
  21. {
  22.  
  23. for(j=1;j<height;j++)
  24. {
  25. printf(" ");
  26. }
  27. if(row==1)
  28. {
  29. printf("*\n");
  30. }
  31.  
  32.  
  33. for(j=0;j<row;j++)
  34. {
  35. if (row!=1 )
  36. {
  37.  
  38. printf("*");
  39. for(j=0;j<z;j++)
  40. {
  41. printf("#");
  42. }
  43. printf("*\n");
  44. z+=2;
  45. }
  46.  
  47. }
  48.  
  49. if(i==k-2)
  50. {
  51. for(j=0;j<z+2;j++)
  52. {
  53. printf("*");
  54. }
  55.  
  56. }
  57. row++;
  58. height--;
  59.  
  60. }
  61.  
  62. //for(j=0;j<z+2;j++)
  63. //{
  64. // printf("*");
  65. //}
  66. //printf("%d", z);
  67. return 0;
  68.  
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement