Lid |
|
Hallo,
Ik heb een probleem met het volledig maken van de nodige Functions. Hiervoor zou ik 3 functies moeten gebruiken, die zijn al ingevuld maar ik krijg niet het gewenste resultaat.
Begin vaste(mag niet veranderd worden) code:
Module ReeksGetallen
Sub Main()
Dim count As Integer = 0
Dim values(1) As Integer
Do
PrintValues(values, count)
'
Console.Write("Value ? : ")
Dim newValue As Integer = Console.ReadLine()
count += 1
'
If count > values.Length Then
values = GetArrayWithDoubledCapacity(values)
End If
'
StoreValue(values, newValue, count - 1)
Loop
'
Console.ReadLine()
End Sub
Module ReeksGetallen Sub Main() Dim count As Integer = 0 Dim values(1) As Integer Do PrintValues(values, count) ' Console.Write("Value ? : ") Dim newValue As Integer = Console.ReadLine() count += 1 ' If count > values.Length Then values = GetArrayWithDoubledCapacity(values) End If ' StoreValue(values, newValue, count - 1) Loop ' Console.ReadLine() End Sub
Ik zou volgende output moeten krijgen(Hetgene achter Value ? is invoer van de gebruiker):
Programmaverloop :
Values (count=0/capacity=2) :
Value ? : 10
Values (count=1/capacity=2) : 10
Value ? : 20
Values (count=2/capacity=2) : 10 20
Value ? : 30
Values (count=3/capacity=4) : 10 20 30
Value ? : 40
Values (count=4/capacity=4) : 10 20 30 40
Value ? : 50
Values (count=5/capacity=8) : 10 20 30 40 50
Value ? : 60
Values (count=6/capacity=8) : 10 20 30 40 50 60
Value ? : 70
Values (count=7/capacity=8) : 10 20 30 40 50 60 70
Value ? : 80
Values (count=8/capacity=8) : 10 20 30 40 50 60 70 80
Value ? : 90
Values (count=9/capacity=16) : 10 20 30 40 50 60 70 80 90
Value ? :
Values (count=0/capacity=2) : Value ? : 10 Values (count=1/capacity=2) : 10 Value ? : 20 Values (count=2/capacity=2) : 10 20 Value ? : 30 Values (count=3/capacity=4) : 10 20 30 Value ? : 40 Values (count=4/capacity=4) : 10 20 30 40 Value ? : 50 Values (count=5/capacity=8) : 10 20 30 40 50 Value ? : 60 Values (count=6/capacity=8) : 10 20 30 40 50 60 Value ? : 70 Values (count=7/capacity=8) : 10 20 30 40 50 60 70 Value ? : 80 Values (count=8/capacity=8) : 10 20 30 40 50 60 70 80 Value ? : 90 Values (count=9/capacity=16) : 10 20 30 40 50 60 70 80 90 Value ? :
Mijn functies tot nu toe zijn:
Function PrintValues(ByVal values As Integer(), ByVal count As Integer)
Console.WriteLine("Values (count=" & count + 1 & "/capacity=")
Return values
End Function
Function GetArrayWithDoubledCapacity(ByVal values As Integer() )
Console.Write(values)
Return values
End Function
Function StoreValue(ByVal values As Integer(), ByVal newValue As Integer, ByVal Count As Integer)
Return values
End Function
End Module
Function PrintValues(ByVal values As Integer(), ByVal count As Integer) Console.WriteLine("Values (count=" & count + 1 & "/capacity=") Return values End Function Function GetArrayWithDoubledCapacity(ByVal values As Integer() ) Console.Write(values) Return values End Function Function StoreValue(ByVal values As Integer(), ByVal newValue As Integer, ByVal Count As Integer) Return values End Function End Module
|