線形探索
Step6

線形探索(Linear Search)

シンプルアルゴリズム----「探し方の基本」

配列やリストの先頭から順番に探す方法
「ある値が入っているかどうか」「何番目にあるか」を調べるときに使います。

📝配列の中から「60」を探す

Dim score() As Integer
score = Array(85, 90, 78, 88, 95, 72, 60, 91, 84, 77)

Dim i As Integer
Dim found As Boolean
found = False

    For i = 0 To UBound(score)
        If score(i) = 60 Then
            Debug.Print "Found at index: " & i
            found = True
            Exit For
        End If
    Next i

    If found = False Then
        Debug.Print "Not found"
    End If

Found at index: 6

📝処理の流れ

85
(0)
🔍
90
(1)
🔍
78
(2)
🔍
88
(3)
🔍
72
(4)
🔍
90
(5)
🔍
60
(6)
91
(7)
84
(8)
77
(9)

📌並び順がバラバラでも使える
📌データが多いと時間がかかる


戻る


© 2026 - Blazor 情処の味方

サポーターズ
Thread Light
An unhandled error has occurred. Reload 🗙