11-07-2024, 05:24 PM
(This post was last modified: 11-07-2024, 05:26 PM by Kernelpanic.)
The entire program basically consists of just one procedur, which only makes sense for an AI.
Without a procedur, and with a query about how many numbers should be drawn.
Without a procedur, and with a query about how many numbers should be drawn.
Code: (Select All)
'Zufallsgenerator - 7. Nov. 2024
Option _Explicit
' Seed the random number generator
Randomize Timer
Dim As Integer anzahlNummern
Dim As Integer count
Dim As Integer newNumber
Dim As Integer isDuplicate
Print
Input "Anzahl der Zufallsnummern (Max 10): ", anzahlNummern
If anzahlNummern > 10 Then
Beep: Print "Maximal 10 Nummern!"
Sleep 2
System
End If
Dim As Integer numbers(anzahlNummern)
count = 0
Dim As Integer i
Do
' Generate a random number between -1 and 71
newNumber = Int(Rnd * 73) - 1
isDuplicate = 0
' Check if the number is already in the array
For i = 1 To count
If numbers(i) = newNumber Then
isDuplicate = 1
Exit For
End If
Next i
' If it's not a duplicate, add it to the array
If isDuplicate = 0 Then
count = count + 1
numbers(count) = newNumber
End If
Loop Until count = anzahlNummern
' Print the selected numbers
Print Using "The ## unique numbers are:"; anzahlNummern
For i = 1 To anzahlNummern
Print numbers(i)
Next i
End