Hi,
I think this program would help.
int i, j, num;
bool flag;
for (i=1;i<=10; i++)
{
num = i;
flag = false;
for(int k = 10 ; k > i ; k--)
{
printf("\t");
}
for (j = 1; j <= (i * 2) - 1; j++)
{
printf("\t %d", num);
if (!flag)
{
num++;
}
else
num--;
if (num >= (i * 2) - 1)
{
flag = true;
}
}
printf("\n");
}
Regards,
Prashant
On Nov 19, 2007 4:01 AM, Robert Ryan <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> I guess, as I understand your answer, each click on the space bar
> represents a space on the grid square. > printf("c"); so for 5 spaces it
> would be
> > printf(" 'c' \n") ; and for 5 and another 5 print(" 'c' \n, 'c' \n");
>
>
>
> Thomas Hruska <[EMAIL PROTECTED]> wrote: Robert Ryan wrote:
> > I have been working on way to make a triangle for a word, but all that i
> get is an infinite loop
> > #include<stdio.h>
> > int main()
> > {
> > int tr=5, r, c, s, o=1;
> > for(c=1; c<=tr; r++)
> > {
> > for(c=1;c<=tr- c;c++)
> > {
> > printf(" ");
> > }
> > for(c=1;c<=o; s++)
> > printf("c");
> > printf("\n") ;
> > o=o++;
> > }
> >
> > Robert Ryan <[EMAIL PROTECTED]> wrote:
> > how would you enter words into a pyramid: like a 3-letter word: ATE
> > T
> > A E
>
> Robert,
>
> When learning to program, it is a LOT easier to solve problems by taking
> a set of sample inputs and using paper to map them out. In your case,
> you should find some graph paper and draw a vertical and a horizontal
> line indicating the top of the screen and the left of the screen
> respectively. Then draw a word with one letter. Each square in the
> grid represents a character position on the screen. So this allows you
> to visualize what you would expect to see with a one letter word.
>
> Repeat the process for a two-letter word, then three letters, four,
> five, six, and seven. Then come up with a mathematical formula to
> determine spacing keeping in mind integer truncation. Make sure the
> formula works by testing enough points until you are satisfied it will
> work as a general purpose algorithm. Then, develop code that uses the
> formula to output the appropriate letters and spaces thus generating the
> pyramid desired. Finally, walk through the code mentally just like the
> computer will execute it and make sure it will operate as expected.
>
> Even then, stuff may slip through the cracks. This is where a debugger
> comes in REALLY handy. A good debugger allows you to see every
> variable's current evaluated value as you step through the code.
> Debuggers allow you to spot where you went wrong and should be an
> important factor when selecting a compiler. Since you are working in C,
> there isn't a whole lot of difference between gdb and the modern Visual
> C++ debugger.
>
> --
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
>
> *NEW* MyTaskFocus 1.1
> Get on task. Stay on task.
>
> http://www.CubicleSoft.com/MyTaskFocus/
>
>
>
>
>
> ---------------------------------
> Get easy, one-click access to your favorites. Make Yahoo! your homepage.
>
>
> [Non-text portions of this message have been removed]
>
>
>