yanghui triangle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • winfield301@gmail.com

    #1

    yanghui triangle

    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
    ............... ..........

  • Vladimir S. Oka

    #2
    Re: yanghui triangle

    winfield301@gma il.com opined:
    [color=blue]
    > 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
    > ............... .........[/color]

    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.programmin g
    - 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

    Comment

    • santosh

      #3
      Re: yanghui triangle

      winfield301@gma il.com wrote:[color=blue]
      > 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
      > ............... .........[/color]

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

      Comment

      • Vladimir S. Oka

        #4
        Re: yanghui triangle

        santosh opined:
        [color=blue]
        > winfield301@gma il.com wrote:[color=green]
        >> 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
        >> ............... .........[/color]
        >
        >[/color]
        printf("1\n1\t1 \n1\t2\t1\n1\t3 \t3\t1\n1\t4\t6 \t4\t1\n1\t5\t1 0\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.

        Comment

        • santosh

          #5
          Re: yanghui triangle

          Vladimir S. Oka wrote:[color=blue]
          > santosh opined:
          >[color=green]
          > > winfield301@gma il.com wrote:[color=darkred]
          > >> 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
          > >> ............... .........[/color]
          > >
          > >[/color]
          > printf("1\n1\t1 \n1\t2\t1\n1\t3 \t3\t1\n1\t4\t6 \t4\t1\n1\t5\t1 0\t10\t5\t1\n") ;
          >
          > Sorry, this does not work as OP wants. Mind the spacing. ;-)[/color]

          You're right. Didn't read close enough.

          Comment

          Working...