Register

OR

Do you already have an account? Login

Login

OR

Don't you have an account yet? Register

Newsletter

Submit to our newsletter to receive exclusive stories delivered to you inbox!

Дан массив A, заполненный 10 произвольными латинскими буквами, упорядочить их любым методом(пузырька или выбором или быстрая сортировка)

более месяца назад
Просмотров : 20    Ответов : 1   

Лучший ответ:

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  Dim Array() As Byte = {102, 103, 105, 105, 104, 108, 101, 109, 111, 113}
  GnomeSort(Array, True)
 End Sub


 ' // Алгоритм гномьей сортировки
 Sub GnomeSort(ByRef Array() As Byte, ByVal ToUpper As Boolean)
  Dim tui As Integer, index As Integer, last As Integer
  If (ToUpper = True) Then tui = 1 Else tui = -1
  index = 1
  last = 2
  Do
   If ((Array(index) * tui) < (Array(index - 1) * tui)) Then
    SWAP(Array(index), Array(index - 1))
    index -= 1
    If (index = 0) Then
     index = last
     last = 1
    End If
   Else
    index = last
    last = 1
   End If
  Loop While (index < (UBound(Array) 1))
  ' // c2fbefeeebede8eb3a20caf3eff0e8ffedeee220c42ec52e2028632920442d6d6f6e3535
 End Sub


 ' // Функция обмена двух переменных
 Private Function SWAP(ByRef ic_a As Integer, ByRef ic_b As Integer) As Boolean
  Dim Dump As Integer = ic_a
  ic_a = ic_b
  ic_b = Dump
  Return True
 End Function

более месяца назад
Ваш ответ:
Комментарий должен быть минимум 20 символов
Чтобы получить баллы за ответ войди на сайт





Вы можете из нескольких рисунков создать анимацию (или целый мультфильм!). Для этого нарисуйте несколько последовательных кадров и нажмите кнопку Просмотр анимации.


Другие вопросы: