scala> last(List(1, 1, 2, 3, 5, 8))
res0: Int = 8
Run Code Online (Sandbox Code Playgroud)
为了得到上面的结果,我写了这段代码:
val yum = args(0).toInt
val thrill:
def last(a: List[Int]): List[Int] = {
println(last(List(args(0).toInt).last)
}
Run Code Online (Sandbox Code Playgroud)
这段代码有什么问题?
我写了一个函数,从一个单词列表中随机选择一个单词.在这里我的代码.但它不能选择一个单词而不能打印.请告诉我我的代码有什么问题.
def long(a: Int, b: Int): String = {
var a = 5
var b = 100
for (i <- args(1)){
if (i > a && i < b){
val rand = new Random(System.currentTimeMillis())
val random_index = rand.nextInt(new_sun .length)
val result = new_sun(random_index)
var guess = println("_ " * result.length)
}
else{
println("You have to input the word with length of 5 < 100")
}
return i.toString
}
}
Run Code Online (Sandbox Code Playgroud) 我可以计算表达式和术语,但我不明白什么是tregonometric函数.他们是表达,条款还是项目?如何编写Pi和tregonometric函数的计算算法.Cos,sin ....如果你知道,请给我一个提示.