32 lines
368 B
C
32 lines
368 B
C
#include <cs50.h>
|
|
#include <stdio.h>
|
|
|
|
void draw(int n);
|
|
|
|
int main(void)
|
|
|
|
{
|
|
int height = get_int("Height; ");
|
|
|
|
draw(height);
|
|
}
|
|
|
|
void draw(int n)
|
|
{
|
|
// Base case, making sure loop has exit condition.
|
|
if (n <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Print a pyramid of height n -1
|
|
draw (n-1);
|
|
|
|
// Print one more row
|
|
for (int i =0; i < n; i++)
|
|
{
|
|
printf("#");
|
|
}
|
|
printf("\n");
|
|
}
|