Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main()
  5. {
  6. int h;
  7. // asking the user to pick the height of the half pyramid
  8. do
  9. {
  10. printf("Pick a number from 1-23: n");
  11. h = GetInt();
  12. }
  13. while (h > 23);
  14.  
  15. // if the number is 5 the half pyramid should look like this
  16. // ----##
  17. // ---###
  18. // --####
  19. // -#####
  20. // ######
  21. // like at the end of super mario
  22.  
  23. int i;
  24. for (i = 0; i < h; i++)
  25. {
  26. char blank;
  27. blank = "s";
  28. char hash;
  29. hash = "#";
  30. printf(blank * (h-(i + 1)));
  31. printf(hash * ((h+1)-(h-(i + 1)))+"n");
  32. }
  33. // I wanted to test my code with s and #
  34. // because I don't know how to print blank spaces in C
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement