
Module Module1
    Function number(ByVal x As String) As Long
        Dim n As Integer
        Do Until x = ""
            x = x.Substring(1)
            n += 1
        Loop
        Return n
    End Function
    Function Space(ByVal n As Long) As String
        Dim line As String = ""
        If n = 0 Then
            Return ""
        Else
            For i As Long = 0 To n - 1
                line &= " "
            Next i
            Return line
        End If
    End Function
    Sub Main()
        Console.WriteLine(" Введите число ступеней:")
        Dim height As Long = CLng(Console.ReadLine())
        Console.WriteLine()
        Dim Bunch(height - 1) As String
        Dim Previous(height - 1) As Long
        For i As Long = 0 To height - 1
            Dim LocalLine(i) As Long

            For j As Long = 0 To i
                If j = 0 Or j = i Then
                    LocalLine(j) = 1
                Else : LocalLine(j) = Previous(j) + Previous(j - 1)
                End If
            Next j

            For z As Long = 0 To i
                Previous(z) = LocalLine(z)
            Next z

            For j As Long = 0 To i
                Bunch(i) &= LocalLine(j).ToString & " "
            Next j
        Next i
        Dim lengthOfLast As Long = number(Bunch(height - 1))
        For i As Integer = 0 To height - 1
            Bunch(i) = Space((lengthOfLast - number(Bunch(i))) \ 2) & Bunch(i)
            Console.WriteLine(Bunch(i))
        Next i
        Console.ReadLine()
    End Sub
End Module
