Stairs Program in C
- From: "bluepgt" <igorpopovic@xxxxxxxxxxxxx>
- Date: 2 Nov 2006 21:47:05 -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 in C
- From: Pascal Bourguignon
- Re: Stairs Program in C
- Prev by Date: Re: Any Crystal Reports gurus? Need Time calc help, plz
- Next by Date: Re: finding primes
- Previous by thread: Any Crystal Reports gurus? Need Time calc help, plz
- Next by thread: Re: Stairs Program in C
- Index(es):
Relevant Pages
|
|