Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main()
- {
- int h;
- // asking the user to pick the height of the half pyramid
- do
- {
- printf("Pick a number from 1-23: n");
- h = GetInt();
- }
- while (h > 23);
- // if the number is 5 the half pyramid should look like this
- // ----##
- // ---###
- // --####
- // -#####
- // ######
- // like at the end of super mario
- int i;
- for (i = 0; i < h; i++)
- {
- char blank;
- blank = "s";
- char hash;
- hash = "#";
- printf(blank * (h-(i + 1)));
- printf(hash * ((h+1)-(h-(i + 1)))+"n");
- }
- // I wanted to test my code with s and #
- // because I don't know how to print blank spaces in C
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement