Advertisement
danyfebrero

(CS50) Mario More

Sep 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <cs50.h>
  2. #include <stdio.h>
  3.  
  4. //funtions declaration
  5. void printhash(int times);
  6. void printblank(int times);
  7.  
  8. int main(void)
  9. {
  10.     int h;
  11.     //askin for the height until is between 1 and 8
  12.     do
  13.     {
  14.         h = get_int("Height: ");
  15.     }
  16.     while (h < 1 || h > 8);
  17.    
  18.     //printing the rows
  19.     for (int row = 0; row < h; row++)
  20.     {
  21.         printblank(h - (row + 1));
  22.         printhash(row + 1);
  23.         printf("  ");
  24.         //making the mirror
  25.         printhash(row + 1);
  26.         printf("\n");
  27.     }
  28. }
  29.  
  30. void printhash(int times)
  31. {
  32.     for (int n = 0; n < times; n++)
  33.     {
  34.         printf("#");
  35.     }
  36. }
  37.  
  38. void printblank(int times)
  39. {
  40.     for (int n = 0; n < times; n++)
  41.     {
  42.         printf(" ");
  43.     }    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement