none
Chronological order RRS feed

  • Question

  • Hey!
    Has managed to create a small program that allows you to select a number of keno numbers between 1 and 70.
    The computer sets the numbers vertically in the order they are random.
    Q: How should I have the computer type the numbers in chronological order with the lowest number first and the highest number last and most in a horizontal row?
    Sincerely
    Karl-Arthur Hyllman
    See my progr.

    TextWindow.WriteLine ("How many KenoNummer do you want? Choose from 1 to 11.")
    i = TextWindow.ReadNumber ()
    TextWindow.WriteLine ("OK! Here are your numbers. Good luck!")
    Sample:
    For AntNr = 1 to (i)
     
      random numbers = Math.GetRandomNumber (70)
      If random numbers = Math.GetRandomNumber (70) Then
        Goto Random
        EndIf
       
    TextWindow.WriteLine (random drummer)
      EndFor
    Wednesday, March 14, 2018 11:29 AM

Answers

  • Your program contains some errors, which prevent the program to run:

    - variable names can NOT contain a space

    - the label Random is not given and label Sample is not used

    The following program does what you ask:

    TextWindow.WriteLine ("How many KenoNummer do you want? Choose from 1 To 11.")
    i = TextWindow.ReadNumber ()
    TextWindow.WriteLine ("OK! Here are your numbers. Good luck!")
    Sample:
    For AntNr = 1 To i
      
      randomnumbers = Math.GetRandomNumber(70)
      If Array.ContainsValue(rand,randomnumbers) Then
        AntNr=Antnr-1    '' used number
      Else
        rand[AntNr]=randomnumbers
      EndIf
      
      TextWindow.WriteLine(randomnumbers)   ''<<< print unsorted list
    EndFor
    
    For i1=1 To i-1   '' sort
      For i2=i1+1 To i
        If rand[i1]>rand[i2] Then
          temp=rand[i1]
          rand[i1]=rand[i2]
          rand[i2]=temp
        EndIf
      EndFor
    EndFor
    For i1=1 To i
      TextWindow.Write(rand[i1]+" ")
    EndFor
    TextWindow.WriteLine("")
    
    It is better to learn to program without GoTo


    Jan [ WhTurner ] The Netherlands


    Wednesday, March 14, 2018 12:45 PM
    Answerer