Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- void PrintPyramid(int height);
- void print_space (int num);
- void print_hash (int num);
- int main(void)
- {
- int i = 0;
- do
- {
- printf("Input integer must be positive and less then 24: ");
- i = GetInt();
- }
- while(i > 23 || i < 0);
- PrintPyramid(i);
- }
- void PrintPyramid(int height)
- {
- for (int i = 1; i <= height; i++)
- {
- print_space(height - i);
- print_hash(i);
- print_space(height/2);
- print_hash(i);
- printf("\n");
- }
- }
- void print_space (int num)
- {
- for (int i = 0; i < num; i++)
- {
- printf(" ");
- }
- }
- void print_hash (int num)
- {
- for (int i = 0; i < num; i++)
- {
- printf("#");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement