获得徽章 0
赞了这篇沸点
2.object class7 {
def main(args: Array[String]): Unit = {
println(s"f(100)的值为:${calculateF100()}")
}
def calculateF100(): Double = {
var result = 0.0
for (n <- 1 to 100) {
if (n % 2 == 1) {
result += 1.0 / n
} else {
result -= 1.0 / n
}
}
result
}
}
def main(args: Array[String]): Unit = {
println(s"f(100)的值为:${calculateF100()}")
}
def calculateF100(): Double = {
var result = 0.0
for (n <- 1 to 100) {
if (n % 2 == 1) {
result += 1.0 / n
} else {
result -= 1.0 / n
}
}
result
}
}
展开
评论
2
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章