A: 2*n
B: n
C: n - 1
D: n + 1
举一反三
- 以下循环中的迭代次数是多少? [br][/br] for i in range(1, n):[br][/br] # 迭代 A: n - 1 B: 2*n C: n D: n + 1
- 请问以下方法的时间复杂度是多少?int n = 10;for (i = 1; i < n; ++i) { for (j = 1; j < n; j += n / 2) { for (k = 1; k < n; k = 2 * k) { x = x + 1; } }} A: O(n^3) B: O(n2logn) C: O(n(logn)*2) D: O(nlogn)
- 下列函数能够求n的阶乘n!的是 A: f = lambda n: n! B: def f(n): s=1 for i in range(n): s = s * i return s C: def f(n): s=1 for i in range(n,0,-1): s = s * i return s D: def f(n): if n == 1: return 1 else: return f(n-1)*n
- 下列表达式的返回结果是________。[n*n for n in range(6) if n*n % 2 == 1]
- 排列\( n(n - 1)(n - 2) \cdots 3 \cdot 2 \cdot 1 \)的逆序数是( ) A: \( {1 \over 2}n(n - 1) \) B: \( n(n - 1) \) C: \( n \) D: \( {n^2}(n - 1) \)
内容
- 0
下面____程序段不能正确显示1!、2!、3!、4!的值。 A: For I=1 To 4 n=1 For j=1 to I n=n*j Next j Print n Next I B: For I=1 To 4 For j=1 to I n=1 n=n*j Next j Print n Next I C: n=1 For j=1 to 4 n=n*j Print n Next j D: n=1:j=1 Do While j<=4 n=n*j Print n j=j+1Loop
- 1
下列程序段能分别正确显示1!、2!、3!、4!的值的是______。 A: For i = 1 To 4 n = 1 For j = 1 To i n = n * j MsgBox(n) Next jNext i B: For i = 1 To 4 For j = 1 To i n = 1 n = n * j Next j MsgBox(n)Next i C: n = 1For i = 1 To 4 For j = 1 To 4 n = n * j MsgBox(n) Next jNext i D: n = 1j = 1Do While j <= 4 n = n * j MsgBox(n) j = j + 1Loop
- 2
下列程序段能且只能显示1!、2!、3!、4!的值的是( )。 A: For i = 1 To 4 n = 1 For j = 1 To i n = n * j Next j MsgBox(n)Next i B: For i = 1 To 4 For j = 1 To i n = 1 n = n * j Next j MsgBox(n)Next i C: n = 1For i = 1 To 4 For j = 1 To 4 n = n * j MsgBox(n) Next jNext i D: n = 1j = 1Do While j <= 4 n = n * j j = j + 1LoopMsgBox(n)
- 3
已知()y()=()ln()x(),则()y()(()n())()=()。A.()(()−()1())()n()n()!()x()−()n()"()role="presentation">()(()−()1())()n()n()!()x()−()n();()B.()(()−()1())()n()(()n()−()1())()!()x()−()2()n()"()role="presentation">()(()−()1())()n()(()n()−()1())()!()x()−()2()n();()C.()(()−()1())()n()−()1()(()n()−()1())()!()x()n()"()role="presentation">()(()−()1())()n()−()1()(()n()−()1())()!()x()-n();()D.()(()−()1())()n()−()1()n()!()x()−()n()+()1()"()role="presentation">()(()−()1())()n()−()1()n()!()x()−()n()+()1().
- 4
在题1和题2中,如果初始时由n个个体组成,总体灭绝的概率是多少? A: (1/2)^n,1 B: 1,(1/2)^n C: n,(1/2)^n D: 1,1/2