Advertisement
danyfebrero

(CS50) Mario Less

Sep 23rd, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <cs50.h>
  2. #include <stdio.h>
  3.  
  4. void printspaces(int n);
  5. void printhash(int n);
  6. int main(void)
  7. {
  8.     int height,spaces;
  9.    
  10.     do
  11.     {
  12.         height = get_int ("Height: ");    
  13.     }    
  14.     while (height < 1 || height >8);    
  15.    
  16.     spaces = height-1;    
  17.    
  18.     for (int i = height; i > 0; i--)
  19.     {  
  20.         printspaces(spaces);
  21.         printhash(height - spaces);
  22.         printf("\n");
  23.         spaces--;
  24.     }
  25. }
  26. void printspaces(int n)
  27. {
  28.     for (int i=0; i<n; i++)
  29.     {
  30.         printf(" ");
  31.     }
  32. }
  33. void printhash(int n)
  34. {
  35.     for (int i=0; i<n; i++)
  36.     {
  37.         printf("#");
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement