Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
37
Task/Pascals-triangle/FreeBASIC/pascals-triangle.freebasic
Normal file
37
Task/Pascals-triangle/FreeBASIC/pascals-triangle.freebasic
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Sub pascalTriangle(n As UInteger)
|
||||
If n = 0 Then Return
|
||||
Dim prevRow(1 To n) As UInteger
|
||||
Dim currRow(1 To n) As UInteger
|
||||
Dim start(1 To n) As UInteger ''stores starting column for each row
|
||||
start(n) = 1
|
||||
For i As Integer = n - 1 To 1 Step -1
|
||||
start(i) = start(i + 1) + 3
|
||||
Next
|
||||
prevRow(1) = 1
|
||||
Print Tab(start(1));
|
||||
Print 1U
|
||||
For i As UInteger = 2 To n
|
||||
For j As UInteger = 1 To i
|
||||
If j = 1 Then
|
||||
Print Tab(start(i)); "1";
|
||||
currRow(1) = 1
|
||||
ElseIf j = i Then
|
||||
Print " 1"
|
||||
currRow(i) = 1
|
||||
Else
|
||||
currRow(j) = prevRow(j - 1) + prevRow(j)
|
||||
Print Using "######"; currRow(j); " ";
|
||||
End If
|
||||
Next j
|
||||
For j As UInteger = 1 To i
|
||||
prevRow(j) = currRow(j)
|
||||
Next j
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
pascalTriangle(14)
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue