Advertisement
OlegGonchar

Mario less

Dec 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.     int h;
  7.     int i;
  8.     int hashes;
  9.     int spaces;
  10.  
  11. // Lets check the user enter a positive number from 0 to 23
  12.  
  13.     do
  14.     {
  15.         printf("Height is: ");
  16.         h = get_int();
  17.     }
  18.     while ( h < 0 || h > 23);
  19.    
  20. // the loop for building rows
  21.  
  22.     for ( i = 1; i <= h; i++)
  23.     {
  24.        
  25. // the loop for writing spaces
  26.  
  27.         for ( spaces = h - i; spaces > 0; spaces--)
  28.         {
  29.             printf(" ");
  30.         }
  31. // the loop for writing hashes
  32.  
  33.         for ( hashes = i + 1 ; hashes > 0 ; hashes--)
  34.         {
  35.             printf("#");
  36.         }
  37.        
  38.         printf("\n");
  39.     }
  40.  
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement