Stairs program
- From: "bluepgt" <igorpopovic@xxxxxxxxxxxxx>
- Date: 2 Nov 2006 20:57:09 -0800
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?
.
- Follow-Ups:
- Re: Stairs program
- From: Andrew Poelstra
- Re: Stairs program
- Prev by Date: Re: equivalent of chomp in perl
- Next by Date: Re: Stairs program
- Previous by thread: equivalent of chomp in perl
- Next by thread: Re: Stairs program
- Index(es):
Relevant Pages
|
|