Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

загрузочный, client, disk, test, virtual, array, сохраненная процедура, applet, class, word, Алгоритм Кнута, Мориса и Пратта (КМП), параметр, breakpoint
 

for valuable work you must have JavaScript (allow active content)

Visual Basic. B.2. Nest of tasks. Nested operators For-For. Sequences

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.1     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 2
        For j = i + 1 To i + 2
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.2     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 2
        For j = i + 1 To i + 2
            For k = j + 1 To j + 2
                xx = xx + 1
            Next k
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.3     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 2
        For j = 1 To i + 1
            For k = 1 To j + 1
                xx = xx + 1
            Next k
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.4     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 4
        For j = 1 To 2
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.5     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 5 To 9
        For j = i - 1 To i + 1
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.6     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 100 To 105
        For j = i - 50 To 60
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.7     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 3
        j = 2 * i - 1
        For k = i To j
            xx = xx + 1
        Next k
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.8     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 5
        For j = 3 To 10 - i
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.9     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 4
        For j = i To 7
            xx = xx + 1
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.10     Answer      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 2
        For j = 1 To 3
            For k = 1 To 4
                xx = xx + 1
            Next k
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.11     Answer      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 2
        xx = xx + 1
    Next i
    For i = 1 To 5
        xx = xx + 1
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.12     Answer      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 3 To 5
        j = i * 2 - 3
        For k = 1 To j
            xx = xx + 1
        Next k
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.13     Answer      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 3
        j = i * 3 - 2
        For k = 1 To j
            xx = xx + 1
        Next k
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.14     Answer      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    xx = 0
    For i = 1 To 3
        For j = 4 To 5
            For k = i To j
                xx = xx + 1
            Next k
        Next j
    Next i
    AA = xx
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.15     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        s = s + i * 3 - 2
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.16     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        s = s + i * i
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.17     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        If i Mod 2 = 0 Then
            s = s + i * 2 - 1
        Else
            s = s + i * 2
        End If
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.18     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        If i Mod 3 = 0 Then
            s = s + i * 2 - 1
        Else
            s = s + i * 2
        End If
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.19     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        If i Mod 2 = 0 Then
            s = s + i * i * i
        Else
            s = s + i * i
        End If
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.20     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        s = s + (i * 2 - 1) * (i * 3 - 2)
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.2.21     Answer

Determine a sequence of numbers the sum of which will be result of the following function.


Function AA() As Integer
    s = 0
    For i = 1 To 10
        For j = 1 To i
            s = s + j
        Next j
    Next i
    AA = s
End Function


 

©   Aliaksandr Prykhodzka    1993 - 2007