One of n lines in a file: Difference between revisions

One of n lines in a file en FreeBASIC
(Added Wren)
(One of n lines in a file en FreeBASIC)
Line 906:
9: 100309
10: 100452</pre>
 
 
=={{header|FreeBASIC}}==
<lang freebasic>Declare Function one_of_n (n As Long) As Long
 
Dim As Long L0, c, elegido(1 To 10)
 
Function one_of_n (n As Long) As Long
'asume que la primera línea es 1
Dim As Long L1, opcion
For L1 = 1 To n
If Int(Rnd * L1) = 0 Then opcion = L1
Next L1
one_of_n = opcion
End Function
 
Randomize Timer
 
For L0 = 1 To 1000000
c = one_of_n(10)
elegido(c) += 1
Next L0
 
For L0 = 1 To 10
Print Using "##. #######"; L0; elegido(L0)
Next L0
 
Sleep</lang>
 
 
=={{header|Go}}==
2,130

edits