Created
July 1, 2013 08:55
-
-
Save soul0592/5899380 to your computer and use it in GitHub Desktop.
Generador de numeros pseudoaleatorios.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def aleatorio(largo,renglon) | |
a = open('keyrb.dat','w') | |
uno = 0 | |
cero = 0 | |
for i in 1..renglon | |
for l in 1..largo | |
random = rand(2) | |
a.write(random) | |
if random == 1 | |
uno += 1 | |
else | |
cero += 1 | |
end | |
end | |
a.write("\n") | |
end | |
a.write("Cero: "+cero.to_s+"\n") | |
a.write("Uno: "+uno.to_s+"\n") | |
a.close() | |
end | |
largo = ARGV[0].to_i | |
renglon = ARGV[1].to_i | |
aleatorio(largo, renglon) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment