Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

шейкерный метод, ряд, college, итерация, FAT32, промежуточный, объяснения, прямое включение, visual basic, value, MYSQL, shl, cycle, counter, computer
 

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

Visual Basic. B.10. Nest of tasks. Tasks on slicing

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.1     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 3
    s1 = a + b
    s2 = b + c
    AA = s1 + b
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.2     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    AA = a * a
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.3     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 5
    b = 7
    a = a * a
    AA = b - 4
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.4     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 3
    d = 4
    s1 = a + b
    s2 = b + c
    s3 = c + d
    AA = s3 - s1
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.5     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 3
    d = 4
    s1 = a + b + c
    s2 = b + c + d
    AA = s1 + s2
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.6     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b1 = a
    b2 = a * a
    b3 = a * a * a
    AA = b1 + b2 + b3
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.7     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    If a > b Then
        c = a + b
    Else
        c = a - b
    End If
    AA = a + b
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.8     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 0
    For d = 1 To a
        c = c + b
    Next d
    AA = a + b
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.9     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 0
    For d = 1 To a
        c = c + b
    Next d
    AA = a + c
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.10     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 1
    b = 2
    c = 0
    For d = 1 To a
        c = c + a
    Next d
    AA = c + a
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.11     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    c = 0
    For i = 1 To 3
        a = i + c
        b = a * a
        c = a + 3
    Next d
    AA = c + 5
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.12     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    tt = 0
    c = 5
    For i = 1 To 3
        a = i + c
        tt = tt + a
    Next i
    AA = tt
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.13     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    tt = 0
    a = 0
    For i = 1 To 7
        a = a + 3
    Next i
    tt = tt + a
    AA = tt
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.14     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    tt = 0
    For i = 1 To 7
        tt = tt + i
    Next i
    tt = 51
    While tt > 3
        tt = tt \ 3
    Wend
    AA = tt
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.15     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a1 = 1
    a2 = 2
    a3 = a1 + a2
    a4 = a2 + 10
    a5 = a2 + a3
    a6 = a1 * a1
    AA = a4 - a6
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.16     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 9
    b = 19
    If a > b Then
        c = 1
    Else
        c = 5
    End If
    AA = a - b
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.17     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 7
    b = 17
    c = 0
    If a > b Then
        c = a + b
    Else
        d = a * b
    End If
    AA = a + d
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.18     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA() As Integer
    a = 7
    b = 19 + a
    c = a * a
    c = c + a
    While c > a
        x = x + c
        a = a - 1
    Wend
    AA = x * x
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.19     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA(x as integer) As Integer
    a = x
    tt = 4
    If a = 1 Then
        a = 2
    Else
        If a = 2 Then
            a = 3
        Else
            If a = 3 Then
                a = 4
            Else
                If a = 4 Then
                    tt = 55
                End If
            End If
        End If
    End If
    AA = tt
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.20     Answer      Pascal-analogue      Java-analogue

Enumerate operators which don't affect the result of function AA.


Function AA(x as integer) As Integer
    a = x
    tt = 4
    If a > 50 Then
        a = 50
    Else
        If a > 40 Then
            a = 40
        Else
            If a > 30 Then
                a = 30
            Else
                If a > 20 Then
                    tt = 5
                Else
                    tt = 6
                End If
            End If
        End If
    End If
    AA = tt
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.21     Answer      Pascal-analogue      Java-analogue

Throw out redundant operators to produce the program of finding maximum element in array


Private Type mo
    A(1 To 10) As Integer
End Type

Private Function AAA(x As mo) As Integer
Dim A(1 To 10) As Integer
    For i = 1 To 10
        A(i) = x.A(i)
    Next i
    tt = A(1)
    AA = A(1)
    bb = A(1)
    For i = 2 To 10
        If A(i) > tt Then
            tt = A(i)
        End If
        If A(i) = AA Then
            AA = A(i)
        End If
        If A(i) < bb Then
            bb = A(i)
        End If
    Next i
    AAA = tt
    AAA = AA
    AAA = bb
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.10.22     Answer      Pascal-analogue      Java-analogue

Throw out redundant operators to produce the program of finding maximum element in array


Private Type mo
    A(1 To 10) As Integer
End Type

Private Function AAA(x As mo) As Integer
Dim A(1 To 10) As Integer
    For i = 1 To 10
        A(i) = x.A(i)
    Next i
    tt = A(1)
    AA = A(1)
    bb = A(1)
    For i = 2 To 10
        If A(i) > tt Then
            tt = A(i)
        Else
            If A(i) = AA Then
                AA = A(i)
            Else
                If A(i) < bb Then
                    bb = A(i)
                End If
            End If
        End If
    Next i
    AAA = tt
    AAA = AA
    AAA = bb
End Function



 

©   Aliaksandr Prykhodzka    1993 - 2007