代码:
package Chapter4
import scala.io.Source
import java.io.PrintWriter
import java.io.File
import java.util._;
import java.text.SimpleDateFormat
//import
object ProduceRandom {
def main(args: Array[String]): Unit = {
val n = 100000
val m = 100
val iString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())
val soutput = "file/output/" + iString;
val w1 = new PrintWriter(new File("file/output/file" + iString + ".txt"))
// for (i<- 0 to n-1) {
// val uu=new Random()
// println(uu.nextInt(10))
arr(i)=uu.nextInt(n);
println(i+":"+arr(i))
// }
// for(i <- 1 to 10 ) println(Rond)
var uu = new Random()
for (i <- 1 to n) { w1.println(uu.nextInt(m)) }
println("success")
w1.close()
}
}
结果:部分
99
92
65
16
76
1
47
85
51
97
60