yanghui triangle

Discussion in 'C Programming' started by winfield301@gmail.com, Mar 25, 2006.

  1. Guest

    how to print the follow one:
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    .........................
    , Mar 25, 2006
    #1
    1. Advertising

  2. opined:

    > how to print the follow one:
    > 1
    > 1 1
    > 1 2 1
    > 1 3 3 1
    > 1 4 6 4 1
    > 1 5 10 10 5 1
    > ........................


    In ISO Standard C, it's fairly easy:

    #include <stdio.h>

    int main(void)
    {
    printf("1\n");
    printf("1 1\n");
    printf("1 2 1\n");
    printf("1 3 3 1\n");
    printf("1 4 6 4 1\n");
    printf("1 5 10 10 5 1\n);
    printf("........................\n");

    return 0;
    }

    Or did you mean algorithmically? In which case:

    - this is a wrong group, try comp.programming
    - a fee is chargeable for doing homeworks

    --
    BR, Vladimir

    I guess I've been wrong all my life, but so have billions of
    other people... Certainty is just an emotion.
    -- Hal Clement
    Vladimir S. Oka, Mar 25, 2006
    #2
    1. Advertising

  3. santosh Guest

    wrote:
    > how to print the follow one:
    > 1
    > 1 1
    > 1 2 1
    > 1 3 3 1
    > 1 4 6 4 1
    > 1 5 10 10 5 1
    > ........................


    printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");
    santosh, Mar 25, 2006
    #3
  4. santosh opined:

    > wrote:
    >> how to print the follow one:
    >> 1
    >> 1 1
    >> 1 2 1
    >> 1 3 3 1
    >> 1 4 6 4 1
    >> 1 5 10 10 5 1
    >> ........................

    >
    >

    printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");

    Sorry, this does not work as OP wants. Mind the spacing. ;-)

    --
    BR, Vladimir

    OCCAM'S ERASER:
    The philosophical principle that even the simplest
    solution is bound to have something wrong with it.
    Vladimir S. Oka, Mar 25, 2006
    #4
  5. santosh Guest

    Vladimir S. Oka wrote:
    > santosh opined:
    >
    > > wrote:
    > >> how to print the follow one:
    > >> 1
    > >> 1 1
    > >> 1 2 1
    > >> 1 3 3 1
    > >> 1 4 6 4 1
    > >> 1 5 10 10 5 1
    > >> ........................

    > >
    > >

    > printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");
    >
    > Sorry, this does not work as OP wants. Mind the spacing. ;-)


    You're right. Didn't read close enough.
    santosh, Mar 25, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Johnson Jr.
    Replies:
    2
    Views:
    442
    Eric Veltman
    Dec 11, 2003
  2. ad

    No triangle in DropDownList

    ad, Jun 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    391
    Eliyahu Goldin
    Jun 5, 2005
  3. henri
    Replies:
    1
    Views:
    376
    Sudsy
    Jun 23, 2004
  4. Diphay Z
    Replies:
    4
    Views:
    401
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=
    Dec 8, 2004
  5. Replies:
    1
    Views:
    3,390
    Betty
    Apr 11, 2005
Loading...

Share This Page