package com.bjsxt.scala
object ObjectAndClass {
def main(args: Array[String]): Unit={
println(1 to 10)
println(1 until 10)
println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
println(1 to (10,2))
println(1 until (10,2))
println(1,10)
for(i<- 1 to 10){
println(i)
}
println("+++++++++++++++++++++++++++++++++++++++++")
for(i<- 1 until 10){
println(i)
}
println("=========================================")
println("打印九九乘法表")
for(i<-1 to 9){
for(j<-1 to 9){
if(i>=j){
print(j+"*"+i+"="+i*j+"\t")
}
}
println()
}
println("*************************************")
for(i<-1 to 9;j<-1 to 9){
for(j<-1 to 9) if(i>=j) print(j+"*"+i+"="+i*j+"\t"); println()
}
println("*************************************")
for(i<-1 to 9;j<-1 to 9){
if(i>=j) print(j+"*"+i+"="+i*j+"\t"); println()
}
println("+++++++++++++++++++++++++++++++++++++++++")
var i=50;
while( i<100){
println("第"+i+"次求婚")
i=i+2
i+=2
}
println("--------------------------------------")
for(i<- 50 to 100){
if(i%2==0){
if (i%3==0){
println(i)
}
}
}
println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
for(i<- 50 to 100) if(i%2==0) if (i%3==0) println(i)
}
}
Scala部分:Scala中的循环(包含to关键字和until关键字的使用,普通递加输出,九九乘法表的打印,while和for循环,if条件语句)
最新推荐文章于 2021-10-31 12:26:52 发布