Created
December 31, 2014 13:34
-
-
Save shigemk2/9c80fe9fe0590dc42243 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 star = "*" * count(i) | |
println(s"$c: $star") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment