Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Pascal triangle  (Read 3442 times)

0 Members and 1 Guest are viewing this topic.

vishuvishal

    Topic Starter


    Beginner
  • Thanked: 3
    Pascal triangle
    « on: August 13, 2010, 04:27:09 PM »
    Hi folk,


    I have a code for pascal triangle

    Code: [Select]
    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    Title Pascal's Triangle
    :Begin
    cls
    (set n=)
    set /p "n=Input (?? Lines) : "
    if not defined n goto :Begin
    (set /a nspace=n-1)
    (set temp_var=!nspace!)
    for /L %%a in (1,1,!n!) do (
    for /L %%n in (1,1,!nspace!) do (
    for /F "Delims=" %%s in ('echo. ') do <nul set /p "=%%s"
    )
    (set /a nspace-=1)
    (set Bil[%%a][1]=1)
    (set Bil[%%a][%%a]=1)
    if %%a gtr 2 for /L %%x in (2,1,!temp_var!) do (
    set /a "prev=%%a-1"
    set /a "prev_coloum=%%x-1"
    call set "temp_1=%%Bil[!prev!][!prev_coloum!]%%"
    call set "temp_2=%%Bil[!prev!][%%x]%%"
    set /a "Bil[%%a][%%x]=temp_1+temp_2"
    )
    for /L %%b in (1,1,%%a) do <nul set /p "=!Bil[%%a][%%b]! "
    echo.
    )
    pause>nul
    goto :Begin
    :END


    It is using concept of array.

    So, I am confused with each lines.
    Can any comment on each lines and explain this to me.

    BC_programmer, Marviland, Victoria.
    Hope to see your comments.


    Thanks and regards
    vish

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    I was trying to dereference Null Pointers before it was cool.

    vishuvishal

      Topic Starter


      Beginner
    • Thanked: 3
      Re: Pascal triangle
      « Reply #2 on: August 15, 2010, 05:49:09 PM »
      I apologize for this. ;D ;D ;D

      But, wanted some explanation.
      You routed me to same old posts.
      I know if you want. You can explain me all these.
      BC programmer.
      Thank you in advance. It will be little lengthy time consuming. But will satisfy my curiosity.
      I also want to devote my knowledge to this forum helping others.
      So, want to be little knowledgeable like you all. Will take time. But, it is not impossible.

      Thanks and regards.
      Vishu