B
bluepgt
I'm trying to write a stairs program. It's supposed to print stairs.
This is what I got:
+---+
| |
+---+---+
| | |
+---+---+---+
| | | |
+---+---+---+---+
| | | | |
+---+---+---+---+---+
| | | | | |
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
Now I can't figure out how to get it to print the inverse to the left
so it looks like a pyramid.
The code:
#include <stdio.h>
void makeTread (int n_tread)
{
int i;
printf("+");
for (i = 0; i < n_tread; i++)
{
printf("---+");
}
printf("\n");
}
void makeRise (int n_rise)
{
int i;
for (i = 0; i < n_rise; i++)
{
printf("| ");
}
printf("\n");
}
void makeStairs (int N)
{
int k;
for (k=1; k <= N; k++)
{
makeTread (k);
makeRise (k + 1);
}
makeTread (N);
}
int
main(void)
{
makeStairs (6);
return (0);
}
Can somebody give me a hint?
This is what I got:
+---+
| |
+---+---+
| | |
+---+---+---+
| | | |
+---+---+---+---+
| | | | |
+---+---+---+---+---+
| | | | | |
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
Now I can't figure out how to get it to print the inverse to the left
so it looks like a pyramid.
The code:
#include <stdio.h>
void makeTread (int n_tread)
{
int i;
printf("+");
for (i = 0; i < n_tread; i++)
{
printf("---+");
}
printf("\n");
}
void makeRise (int n_rise)
{
int i;
for (i = 0; i < n_rise; i++)
{
printf("| ");
}
printf("\n");
}
void makeStairs (int N)
{
int k;
for (k=1; k <= N; k++)
{
makeTread (k);
makeRise (k + 1);
}
makeTread (N);
}
int
main(void)
{
makeStairs (6);
return (0);
}
Can somebody give me a hint?