8、阅读以下程序,填写运行结果_______________. def f(n): if n%2==0: print('偶',end='') #此处''为空字符串 else: print('奇',end='') #此处''为空字符串 for i in [1,5,2,6,7]: f(i)
8、阅读以下程序,填写运行结果_______________. def f(n): if n%2==0: print('偶',end='') #此处''为空字符串 else: print('奇',end='') #此处''为空字符串 for i in [1,5,2,6,7]: f(i)
参考答案和解析
14
相关考题:
(12)下列程序段的运行结果是 Sub sele() Dim n As Integer I=21:n=3 Do While in I=i-n Loop Print i End SubA.2 B.4 C.5 D.3
设有如下程序: Private Sub Form. Click( ) Dim s As Long,f As Long Dim n As Integer,i As Integer f=1 n=4 For i=1 To n f=f*i s=s+f Next i Print s End Sub 程序运行后,单击窗体,输出结果是( )。A.32B.33C.34D.35
阅读下列程序: Function func(n As Integer)As Integer Sum = 0 For i = 1 To n Sum = Sum + (i + 1)* i Next i func = Sum End Function.Private Sub Command1_Click () Dim a As Integer a= 5 s = func (A)Print s End Sub 程序运行后,单击命令按钮,输出的结果为A.80B.60C.70D.15
有以下程序 main ( ) { int i,n=0; for (i=2 ;i<5;i++) { do { if (i%3) continue; n++; } while(!i); n++; } print f ( "n=%d\n" , n); } 程序执行后的输出结果是A.n=5B.n=2C.n=3D.n=4
设有如下程序: Private Static Function Fac(n As Integer)As Integer Dim f As Integer f=f+n Fac=f End Function Private Sub Form_Click( ) Dim I As Integer For 1=2 To 3 Print"#";I“=”Fac(1) Next I End Sub 程序运行后,单击窗体,在窗体上显示的是A.#2=2 #3=3B.#2=2 #3=5C.#;2=2 #;3=3D.#;2=2 #3;=5
以下能够正确计算n!的程序是A.Private Sub Command1_Chck( ) n=5:x=1 Do x=x*i i=i+1 Loop While i<n Print x End SubB.Private Sub Command1_Click( ) n=5:x=1:i=l Do x=x*i i=i+1 Loop While i<n Print x End SubC.Private Sub Command1_Click( ) n=5:x=1:i=l Do x=x*i i=i+1 Loop While i<=n Print x End SubD.Private Sub Command1_Click( ) n=5:x=1:i=l Dox=x*i i=i+1 Loop While i>n Print x End Sub
以下能够正确计算n!的程序是A.Private Sub Command1 Click() n=5:x=1 Do x=x * I I=I + 1 Loop While I < n Print x End SubB.Private Sub Command1_Click() n=5:X=1:I=1 Do X=X*I I=I + 1 Loop While I <n Print x End SubC.Private Sub Command1_Click() n=5:X=1:I=1 Do X=X * I I=I + 1 Loop While I<=n Print X End SubD.Private Sub Command1_Click() n=5:X=1:I=1 Do x=x * I I=I + 1 Loop While I>n Print X End Sub
现有如下程序: Private Sub Command1_Click() s=0 For i=1 To 5 s=s+f(5+i) Next Print s End Sub Public Function f(x As Integer) If x>=10 Then t=x+1 Else t=x+2 End If f=t End Function 运行程序,则窗体上显示的是( )。A.38B.49C.61D.70
有如下程序: Private Sub Form_Click( ) Dim i As Integer, Sum As Integer Sum = 0 For i = 2 To 10 If i Mod 2=0 And i Mod 3<>0 Then Sum = Sum + i End If Next Print Sum End Sub 程序运行后,单击窗体,输出结果为A.12B.30C.24D.18
以下能够正确计算n! 的程序是( )。A.Private Sub Command1_Click( ) n=5:x=l Do x=x*i i=i+1 Loop While i < n Print x End SubB.Private Sub Command1_Click( ) n=5:x=1:i=1 Do x=x*i i=i+1 Loop While i < n Print x End SubC.Private Sub Command1_Cliek( ) n:5:x=1:i=1 Do x=x* i i:i+1 Loop While i < = n Print x End SubD.Private Sub Command1_Cliek( ) n=5:x:1:i=1 Do x=x*i i=j+1 Loop While i > n Print x End Sub
阅读程序: Function Fun(a As Integer) Static C b=0:b=b+2:c=c+2 F=a*b*c End Function Private Sub Command1_Click() Dim a As Integer a=2 For i=1 To 2 Print Fun(A) ; Next End Sub 运行上面的程序,单击命令按钮,输出结果为A.8 16B.9 18C.10 20D.7 14
下列程序段的运行结果是( )。 Subsele() Dim n As Integer i=21:n=3 Do While i>n i=i-n Loop Print i End SubA.2B.4C.5D.3
有以下程序 int f (int A) { return a%2; } main ( ) { int s[8]={1,3,5,2,4,6),i,d=0; for (i=0; f(s[i]; i++) d +=s[i]; print f ("%d\n", D) ; } 程序运行后的输出结果是A.9B.11C.19D.21
下列程序段的执行结果为 m=1 n=1 Select Case m Case 1 Select Case n Case 0 print"A" Case 1 Print"B" End Select Case 2 Print"C" End SelectA.AB.BC.CD.0
有如下程序: Private Sub Form_Click() Dim i As Integer, Sum As Integer sum=0 For i=2 To 10 If i Mod 2<>0 And i Mod 3=0 Then sum=sum+i End If Next i Print sum End Sub 程序运行后,单击窗体,输出结果为______。A.12B.30C.24D.18
有以下程序includeint f(int n){if(n==1 )return 1;else return f(n-1 )+ 1;}void 有以下程序#include<iostream.h>int f(int n){if(n==1 )return 1;else return f(n-1 )+ 1;}void main() {int i,j=0;for(i=1 ;i<3;i++) j+=f(i);cout<<j<<end1;}程序运行后的输出结果是( )。A.4B.3C.2D.1
阅读程序: Function F(a As Integer) b=0 Static c b=b+1 c=c+1 F=a+b+c End Function Private Sub Command1_Click() Dim a As Integer a=2 For i=1 To 3 Print F(A)Next i End Sub 运行上面的程序,单击命令按钮,输出结果为 ______。A.4 4 4B.4 5 6C.4 6 8D.4 7 9
下列程序段的执行结果为 m=1 n=1 Select Case m Case 1 Select Case n Case 0 Print" * * 0 * *" Case 1 Print" * *1* *" End Select Case 2 Print" * * 2 * *" End SelectA.**0**B.**1**C.**2**D.0
若有以下程序: include usingnamespace std; class Sample { private: const int n; 若有以下程序:include <iostream>using namespace std;class Sample{private:const int n;public:Sample(int i) :n(i) {)void print(){cout<<"n="<<n<<end1;}};int main(){sample a(10);a.print();return 0;}上述程序运行后的输出结果是【 】。
下列程序段的运行结果是( )。 Sub sele() Dim n As Integer i=21: n=3 Do While i > n i=i-n Loop Print i End SubA.2B.4C.5D.3
阅读程序: Function Fun( a As Integer) Static c b=0:b=b+2:c=c+2 F=a*b*c End Function Private Sub Commandl _ Click( ) Dim a As Integer a=2 For i = 1 To 2 Print Fun (a); Next End Sub 运行上面的程序,单击命令按钮,输出结果为A.8 16B.9 18C.10 20D.7 14
以下能够正确计算n!的程序是______。A.Private Sub Commeadl_Click() n=5: x=1 Do x=x*i i=i+1 Loop While i<n Print x End SubB.Private Sub Command1_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop While i<n Print x End SubC.Private Sub Command1_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop Whilei<=n Print x End SubD.Private Sub Commsndl_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop While i>n Print x End Sub
阅读下列程序: Private Sub Form Click() Dim i As Integer, sum As Integer For i = 2 To 10 If i Mod 2 <> 0 Then Print i; Else sum = sum + i End If Next i Print sum End Sub 程序运行后,单击窗体,在窗体上的输出结果是A.3 5 7 9 30B.1 3 5 7 9C.2 4 6 8 20D.11 15 17 19 20
阅读程序: Function F(a As Integer) b=0 Static c b=b+1 c=c+1 f=a+ b+ c End Function Private Sub Command1_Click() Dim S As Integer a=2 For i=1 To 3 Print P(A) Next i End Sub运行上面的程序,单击命令拄钮,输出结果为______ 。A.4 4 4B.4 5 6C.4 6 8D.4 7 9
有以下程序 int a=2; int f(int n) { static int a=3; int t=0; if(n%2) {static int a=4; t+=a++;} else {static int a=5; t+=a++;} return t+a++; } main ( ) { int s=a, i; for (i=0;i<3; i++) s+=f (i) print f ("%d\n" , s ); } 程序运行后的输出结果是A.26B.28C.29D.24
有以下程序 include int f(iht n) { if(n==1) return 1; else return f(n-1)+ 有以下程序 #include<iostream.h> int f(iht n) { if(n==1) return 1; else return f(n-1)+1;} void main( ) { iht i,j=0; for(i=1;i<3;i++)j+=f(i); cout < < j;} 程序运行后的输出结果是A.4B.3C.2D.1
下列程序段的执行结果为 m=1 n=1 Select Case m Case 1 Select Case n Case 0 Print" * * 0 * *" Case 1 Print" * *.* *" End Select Case 2 Print"* *,2 * *," End SelectA.* * 0 * *B.* * 1 * *C.* * 2 * *D.0
以下程序输出结果是 include main ( ){int i=0,a=0; while ( i 以下程序输出结果是 #include <stdio.h> main ( ) { int i=0,a=0; while ( i<2 0 ) { for(;;) { if ((i%10) ==0) break; else i--; } i+=11; a+=i; } print f ( "%d\n" , a); }A.21B.32C.33D.11