Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

case, обзоры, Алгоритм Кнута, Мориса и Пратта (КМП), with, перемещение минимального элемента, client, cell, select, граф, format, ряд, выбор, registr
 

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

Visual Basic. B.14. Nest of tasks. Tasks on substitution of operators

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.1     Answer      Pascal-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 15
    a = 0
    s = 0
    Do
        a = a + 1
        _____
    Loop Until a = 5
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.2     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 40
    s = 0
    For i = 1 To 5
        _____
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.3     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer ' 21
    s = 0
    For i = 1 To 5
        If i Mod 2 = 0 Then
            _____
        Else
            _____
        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.14.4     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 18
    s = 0
    For i = 1 To 5
        If i Mod 3 > 0 Then
            _____
        Else
            _____
        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.14.5     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 30
    s = 0
    For i = 1 To 3
        For j = 1 To i
            _____
        Next j
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.6     Answer      Pascal-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 5
    ____
    If s = 5 Then
        Do
        Loop Until False
    End If
    While s > 16
        _____
    Wend
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.7     Answer      Pascal-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 45
    _____
    Do
        _____
    Loop Until s > 31
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.8     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 53
Dim A(1 To 4) As Integer
    For i = 1 To 4
        _____
    Next i
    s = 0
    For i = 1 To 3
        s = s + A(i) * A(i + 1)
    Next i
    AA = s
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.14.9     Answer      Pascal-analogue      Java-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


Function AA() As Integer    ' 90
    s = 0
    For i = 1 To 3
        _____
    Next i
    k = 0
    For j = 1 To 4
        _____
    Next j
    s = s * k
    AA = s
End Function

 

©   Aliaksandr Prykhodzka    1993 - 2007