import java.io.{File, PrintWriter}
import scala.io.StdIn
// Scala中的For循环
var row = 1
var col = 1
for (row <- 1 to 9) {
for (col <- 1 to row) {
print(col + "*" + row + "=" + (row * col) + " ")
}
println()
}
// Scala中的I/O操作
val writer = new PrintWriter(new File("target.txt"))
writer.write("Sweetie Lynn")
writer.close()
// Scala中的标准输入
val in = StdIn.readLine()
println(in)
// Scala中的if语句
var x = 10
var y = 20
if (x > y) {
println(" x > y ")
} else {
println(" x < y ")
}
网友评论