В заданном векторе размерности N подсчитать количество компонент, принадлежащих отрезку [ a; b ] — Visual Basic(Бейсик)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Sub Main()
    Dim N As Integer = 10
    Dim a As Integer = 3
    Dim b As Integer = 8
    Dim vector() As Integer = {2, 4, 6, 8, 10, 3, 5, 7, 9, 1}
    Dim count As Integer = 0
 
    For i As Integer = 0 To N - 1
        If vector(i) >= a AndAlso vector(i) <= b Then
            count += 1
        End If
    Next
 
    Console.WriteLine("Количество компонент на отрезке [a, b]: {0}", count)
End Sub

Leave a Comment