Advertisement
N1K003

Untitled

Aug 8th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main(void)
  6. {
  7.         int height = 0;
  8.         char buf[150] = { 0 };
  9.  
  10.         while (height < 1 || height > 23)
  11.         {
  12.                 printf("Height: ");
  13.                 if (fgets(buf, sizeof(buf), stdin) != NULL)
  14.                         height = atoi(buf);
  15.         }
  16.  
  17.         for (int i = 0; i < height; i++)
  18.         {
  19.                 for (int j = 0; j < height - i - 1; j++)
  20.                         printf(" ");
  21.  
  22.                 for (int j = 0; j < i + 1; j++)
  23.                         printf("#");
  24.                 printf("#\n");
  25.         }
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement