Sei sulla pagina 1di 2

Name: __________________________________________ Signature: __________________ Group#: __________

A. PROCEDURES

Dim intErnet, Sum As Integer


Sub Main()
Dim intA As Integer = Console.ReadLine
Dim intB As Integer = Console.ReadLine
intErnet = Func(intB, intA)
'input values for intA and intB, respectively
'a. 2 4
'b. 5 2
'c. 1.5 5

Select Case intErnet


Case 5
Call Lay(intA, intB)
Call Lay(intB, intA)
Case 2 To 6
Call Bog(intB)
intA = Hall(intB, Hall(intA, intB))
Case Else
Call Lay(intA, intB)
End Select
Console.WriteLine(intA)
Console.WriteLine(intB)
Console.WriteLine(intErnet)
Console.WriteLine(Sum)
Console.ReadLine()
End Sub
Function Func(ByVal Y As Integer, ByVal X As Integer) As Integer
Dim intCounter As Integer
For intCounter = 1 To Y Step (X / 2)
Sum += Sum - X
intCounter += 1.5
Next
Return intCounter
End Function
Function Hall(ByVal X As Integer, ByVal Y As Integer) As Integer
X += 1
Y -= 1
If X >= Y Then
Return X - Y
Else
Hall = X + Y
Exit Function
End If
End Function
Sub Lay(ByRef X As Integer, ByVal Y As Integer)
X *= 2
Y *= 2
If Y > X Then
Call Bog(Y)
Sum += Y
End If
End Sub
Sub Bog(ByRef X As Integer)
Dim temp As Integer
temp = X
X = intErnet
intErnet = temp
End Sub
B. ARRAYS

Sub Main()
Dim intArray() As Integer = {1, 5, 6}
Dim intFixed(2) As Integer
Dim sngA As Single = Console.ReadLine()
Dim sngB As Single = Console.ReadLine()
Dim intN As Integer = Console.ReadLine()
Dim sngSum As Single = 0
'input values for sngA, sngB and intN, respectively
'a. 1 9 3
'b. 1 1 4
'c. 1 8 3

Select Case Math.Round((sngB \ sngA - 1), 0)


Case 0
ReDim intArray(intN - 1)
intArray(intN - 1) = sngA + sngB
For intCounter As Integer = 0 To (intN - 1)
sngSum += intArray(intCounter)
Next
Case Is < 5
For intCounter As Integer = 0 To UBound(intFixed)
intFixed(intCounter) = intArray(intCounter) + sngB
Next
sngSum = intFixed(1) + intFixed(2) + sngA
Case 2, 5, 8
ReDim Preserve intArray(intN - 1)
For intCounter As Integer = 1 To UBound(intArray)
intArray(intCounter) = 1
Next
For intCounter = 0 To (intN - 1)
sngSum += intArray(intCounter)
Next
Case Else
ReDim Preserve intArray(sngB)
sngSum = intArray(0) + intArray(2) + intArray(sngB)
End Select
Console.WriteLine("TestExpression = " & CStr(Math.Round((sngB \ sngA - 1), 0)))
Console.WriteLine("sngSum = " & CStr(sngSum))
Console.WriteLine("intArray(" & (UBound(intArray) & ") = " & CStr(intArray(UBound(intArray)))))
Console.WriteLine("intFixed(" & (UBound(intFixed) & ") = " & CStr(intFixed(UBound(intFixed)))))
'List the final elements of intArray and intFixed for each set of inputs

End Sub

Potrebbero piacerti anche