Module Module1
    Function number(ByVal x As String, ByVal character As String) As Integer
        Dim n As Integer
        Do Until x.IndexOf(character) = -1
            x = x.Substring(x.IndexOf(character) + 1)
            n += 1
        Loop
        Return n
    End Function
    Function Parity(ByVal x As Integer) As Boolean
        If x Mod 2 = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
    Sub Main()
        Do
            Console.WriteLine(" Введите перестановку:")
            Dim transposition As String = Console.ReadLine()
            Dim n As Integer = number(transposition, " ")
            Dim array(n) As Integer
            For i As Integer = 0 To n - 1
                array(i) = Integer.Parse(transposition.Substring(0, transposition.IndexOf(" ")))
                transposition = transposition.Substring(transposition.IndexOf(" ") + 1)
            Next i
            array(n) = Integer.Parse(transposition)
            Dim trans As Integer = 0
            For i As Integer = n To 0 Step -1
                For j As Integer = 1 To i
                    If array(j) >= array(j - 1) Then
                    Else
                        array(j) += array(j - 1)
                        array(j - 1) = array(j) - array(j - 1)
                        array(j) = array(j) - array(j - 1)
                        trans += 1
                    End If
                Next j
            Next i
            If Parity(trans) = True Then
                Console.WriteLine(" Четная перестановка")
            Else
                Console.WriteLine(" Нечетная перестановка")
            End If
            Console.ReadLine()
            Console.Clear()
        Loop
    End Sub

End Module
