Lionheart008
23-02-2009, 17:21
dear thinbasic friends,
hello rainy day, short question:
can anybody help for this little console script??? I will learn to make it better :)
'Demonstrationsprogram
'für Haeufigkeiten, später lottoprogramm by lionheart, try 1, 20.feb.2009
uses "console", "math"
dim r as integer
dim p as single
dim n, i, anzahl(6) as long
n = 5000
randomize timer
anzahl(1) = 1, 2, 3, 4, 5, 6
Console_SetScreenBufferSize(80, 25)
PRINTL ("--------hallo liebes haeufigkeiten programm-------")
PRINTL ("-------increase random example for n = 5000--------")
PrintL
'n Zufallszahlen generieren
for i = 1 to n
r = Int(RND*5)+1
anzahl(r) += 1
next i
PRINTL ("--------Prozente berechnen ! -------")
'Jetzt die Bilanz ausgeben:
PrintL ("Haeufigkeiten in Prozenten:")
for i = 1 to 6
'PrintL format$(i,"##: ")
PrintL ( "#.00: > ###.00: (", i, anzahl(i))
'Berechnung des Anteils in Prozent:
anzahl(i) *= 100
p = anzahl(i) / n
PrintL ("##.### %", p) ',p
PrintL
Next i
Console_Write("Ok, now press any key to exit")
Console_WaitKey
would like to have a list with numbers for "###" and should have done something with format$ but don't check it... was too tired last night...
the script works but not in the original way I wished...
best regards, more will come later,
lionheart
hello rainy day, short question:
can anybody help for this little console script??? I will learn to make it better :)
'Demonstrationsprogram
'für Haeufigkeiten, später lottoprogramm by lionheart, try 1, 20.feb.2009
uses "console", "math"
dim r as integer
dim p as single
dim n, i, anzahl(6) as long
n = 5000
randomize timer
anzahl(1) = 1, 2, 3, 4, 5, 6
Console_SetScreenBufferSize(80, 25)
PRINTL ("--------hallo liebes haeufigkeiten programm-------")
PRINTL ("-------increase random example for n = 5000--------")
PrintL
'n Zufallszahlen generieren
for i = 1 to n
r = Int(RND*5)+1
anzahl(r) += 1
next i
PRINTL ("--------Prozente berechnen ! -------")
'Jetzt die Bilanz ausgeben:
PrintL ("Haeufigkeiten in Prozenten:")
for i = 1 to 6
'PrintL format$(i,"##: ")
PrintL ( "#.00: > ###.00: (", i, anzahl(i))
'Berechnung des Anteils in Prozent:
anzahl(i) *= 100
p = anzahl(i) / n
PrintL ("##.### %", p) ',p
PrintL
Next i
Console_Write("Ok, now press any key to exit")
Console_WaitKey
would like to have a list with numbers for "###" and should have done something with format$ but don't check it... was too tired last night...
the script works but not in the original way I wished...
best regards, more will come later,
lionheart