Created
December 31, 2014 15:10
-
-
Save shigemk2/bb5cbe5e408dfd9136a5 to your computer and use it in GitHub Desktop.
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
import scala.util.Random | |
var math = 0.0 | |
var sum = 0 | |
var r = new Random | |
var count = new Array[Int](13) | |
for (i <- 1 to 100) { | |
var math = 0.0 | |
for (i <- 1 to 12) { | |
math += r.nextDouble | |
} | |
sum = (math + 0.5).floor.toInt | |
count(sum) += 1 | |
} | |
for (i <- 0 to 12) { | |
val c = i - 6 | |
val spc = " " * (2 - c.toString.length) | |
val star = "*" * count(i) | |
println(s"$spc$c: $star") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment