login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Functies toevoegen en combineren

Offline Jimbo - 23/12/2011 19:58
Avatar van JimboLid 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:
  1. Module ReeksGetallen
  2. Sub Main()
  3. Dim count As Integer = 0
  4. Dim values(1) As Integer
  5. Do
  6. PrintValues(values, count)
  7. '
  8. Console.Write("Value ? : ")
  9. Dim newValue As Integer = Console.ReadLine()
  10. count += 1
  11. '
  12. If count > values.Length Then
  13. values = GetArrayWithDoubledCapacity(values)
  14. End If
  15. '
  16. StoreValue(values, newValue, count - 1)
  17. Loop
  18. '
  19. Console.ReadLine()
  20. End Sub


Ik zou volgende output moeten krijgen(Hetgene achter Value ? is invoer van de gebruiker):
Programmaverloop :
  1. Values (count=0/capacity=2) :
  2. Value ? : 10
  3. Values (count=1/capacity=2) : 10
  4. Value ? : 20
  5. Values (count=2/capacity=2) : 10 20
  6. Value ? : 30
  7. Values (count=3/capacity=4) : 10 20 30
  8. Value ? : 40
  9. Values (count=4/capacity=4) : 10 20 30 40
  10. Value ? : 50
  11. Values (count=5/capacity=8) : 10 20 30 40 50
  12. Value ? : 60
  13. Values (count=6/capacity=8) : 10 20 30 40 50 60
  14. Value ? : 70
  15. Values (count=7/capacity=8) : 10 20 30 40 50 60 70
  16. Value ? : 80
  17. Values (count=8/capacity=8) : 10 20 30 40 50 60 70 80
  18. Value ? : 90
  19. Values (count=9/capacity=16) : 10 20 30 40 50 60 70 80 90
  20. Value ? :



Mijn functies tot nu toe zijn:
  1. Function PrintValues(ByVal values As Integer(), ByVal count As Integer)
  2. Console.WriteLine("Values (count=" & count + 1 & "/capacity=")
  3. Return values
  4. End Function
  5. Function GetArrayWithDoubledCapacity(ByVal values As Integer() )
  6. Console.Write(values)
  7.  
  8. Return values
  9. End Function
  10.  
  11. Function StoreValue(ByVal values As Integer(), ByVal newValue As Integer, ByVal Count As Integer)
  12.  
  13. Return values
  14. End Function
  15. End Module

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Je moet ingelogd zijn om een reactie te kunnen posten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.177s