单选题:h0005. 编写一个过程countdown(n:Int),打印从n到0的数字?
编写一个过程countdown(n:Int),打印从n到0的数字?
A.
def countdown(n:Int){
0 to n foreach print
}
B.
def countdown(n:Int){
(0 until n).reverse foreach print
}
C.
def countdown(n:Int){
(0 to n).reverse foreach print
}
D.
def countdown(n:Int){
(0 to n-1).reverse foreach print
}
答案:C
A.
def countdown(n:Int){
0 to n foreach print
}
B.
def countdown(n:Int){
(0 until n).reverse foreach print
}
C.
def countdown(n:Int){
(0 to n).reverse foreach print
}
D.
def countdown(n:Int){
(0 to n-1).reverse foreach print
}
答案:C