网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序运行结果是:() a=[1,2,1,2,3,3,3,3] result=0 for i in a: result+=i print (result)
A.16
B.15
C.17
D.18
参考答案和解析
C 解析:本题程序的功能是对数组元素赋值,难点是对表达式4*(i-2*(i>3))%5的分析。
更多 “下列程序运行结果是:() a=[1,2,1,2,3,3,3,3] result=0 for i in a: result+=i print (result)A.16B.15C.17D.18” 相关考题
考题
关于JAVA初级的代码计算问题
下面的方法,当输入为2的时候返回值是多少?()publicintgetValue(inti){intresult=0;switch(i){case1:result=result+i;case2:result=result+i*2;case3:result=result+i*3;}returnresult;}
考题
下面程序的运行结果是#includeint fun(int a[]. int n){int result=l:for(int i=1;iresult=result*a[i];return result;}void main(){int a[3]={3,4,5};cout}A.12;B.15;C.20;D.60
考题
下面程序的运行结果是 include int fun(int a[ ] ,int n) { int result=1; for(in
下面程序的运行结果是#include<iostream.h>int fun(int a[ ] ,int n){int result=1;for(int i=1;i<n;i++)result=result * a[i] ;retum result;}void main( ){int a[3] ={3,4,5};coutA.12B.15C.20D.60
考题
下面程序段的输出结果是( )。 public class Test { public static void main ( String[] args) { int result=0; for ( int i=1;i<=5;i++) { if ( i%2==0 ) continue; result + =i; } System. out. println ("result is " + result ); } }A.result is 7B.result is 8C.result is 9D.result is 10
考题
以下程序的路径数为______。 If(a0) Result=a*b: } if(c>8)result+=1;A) 3B) 6C) 8D)
以下程序的路径数为______。If(a<8){If(b>0)Result=a*b:}if(c>8) result+=1;A) 3B) 6C) 8D) 12A.B.C.D.
考题
程序:classTestApp{intipublicstaticvoidmain(String[]args){for(inti=0;i5;i++)System.out.print(i+1);System.out.println(i);(i没有定义)}}上述程序运行后的结果是哪项?()
A.123456B.123455C.123450D.编译错误
考题
程序:classTestApp{publicstaticvoidmain(String[]args){for(inti=0;i5;i++)System.out.print(i+1);System.out.println(i);}}上述程序运行后的结果是哪项?()
A.123456B.123455C.123450D.编译错误
考题
下面程序的运行结果是( )。 #includeiostream.h int fun(int a[],int n) { int resuh=1; for(inl i=1;i11;1‘++) result=result * a[i]; retum result; } void main int a[3]={3,4,5}: coutfun(a,3)endl: }A.12B.15C.20D.60
考题
下面程序的运行结果是()。includeintfun(inta[],int n){int result=1;for(int i=“i
下面程序的运行结果是( )。 #include<iostream.h> intfun(inta[],int n) { int result=1; for(int i=“i<n;i++) result’resultxa[i]; return result; } void main() { inta[3]={3,4,5}; cout<<fun(a,3)<<endl; }A.12B.15C.20D.60
考题
以下程序的执行结果是______ include include void print(int n) { if(n
以下程序的执行结果是______include<iostream.h>include<iomanip.h>void print(int n){if(n!=0){print(n-1);for(int i=1;i<=n;i++=cout<<setw(3)<<i;cout<<endl;}}void main(){print (4);}
考题
假定a=3,下列程序的运行结果是()。ineludeint fun(int n);void main(){cout
假定a=3,下列程序的运行结果是( )。 #inelude<iostream.h> int fun(int n); void main() { cout<<"Please input a number:"; int a,result=0; cin>>a; result=fun(a); tout<<result<<end1; } intfun(int n) { int p=1,result=0; for(int i=1;i<=n;i++) { p*=i; result+=p; } return result; )A.4B.8C.9D.20
考题
下列程序的输出结果是______。 #define A 100 main() { int i=0,sum=0; do{ if(i=(i/2)*2)continue; sum+=i; }while(++i<A); print("%d\n",sum); }A.2500B.2050C.4D.0
考题
运行下列程序,在立即窗口显示的结果是( )。 PrivateSub Command0_Click( ) Dim I AsInteger,J AsInteger For I=2To 10 For J=2 To1 If I modJ=0 Then Exit For Next J IfJsqr(I)Then Debug.Print I; Next I End SubA.1579B.468C.3579D.2357
考题
下面程序的运行结果是( )。 #includeiostream.h intfun(inta[],intn) { intresult=1; for(inti=1;i(n;i++) result=result*a[i]; returnresult; } voidmain( ) { inta[3]={3,4,5); coHtfun(a,3)endl; }A.12B.15C.20D.60
考题
有以下程序: void sum(int * a) {a[0]=a[1];} main() { int aa[10]={1,2,3,4,5,6,7,8,9,10},i; for(i=1;i>0;i--)sum(aa[i]); print("%d\n",aa[0]); } 程序运行后的输出结果是 ______。A.4B.3C.2D.1
考题
下面程序的运行结果是includeint fun(inta[],int n){ int result=1; for(int i=1:i
下面程序的运行结果是 #include<iostream.h> int fun(inta[],int n) { int result=1; for(int i=1:i<n;i++) result=result*a[i]; remm result; } void main() { int a[3]={3,4,5}; cout <<fun(a,3) <<end1; }A.12B.15C.20D.60
考题
运行下列程序,在立即窗口显示的结果是( )。PrivateSub Command0_Click( )Dim I AsInteger,J AsIntegerFor I=2To 10For J=2 To1If I modJ=0 Then Exit ForNext JIfJsqr(I)Then Debug.Print I;Next IEnd SubA.1579B.468C.3579D.2357
考题
下面程序的运行结果是______。 Dim a,i,s a=Array("6","5","a","b","2","1") s=0 i=0 Dw While a(i)>="0" And a(i)<="9" s=10* s+a(i)-"0" Print s i=i+2 LoopA.12ba56B.652C.6D.62
考题
在窗体中使用一个文本框(名为n)接受输入的值,有一个命令按钮run,事件代码如下: Private Sub run_Click() result="" For i=1 To Me!n For j=1 To Me!n result=result+"*" Next j result=result+Chr(13)+Chr(10) Next i MsgBox result End Sub 打开窗体后,如果通过文本框输入的值为4,单击命令按钮后输出的图形是( )。A.* * * * * * * * * * * * * * * *B. * * * * * * * * * * * * * * * *C. * * * * * * * * * * * * * * * * * * * * * * * * * * * *D. * * * * * * * * * * * * * * * *
考题
假定a=3,下列程序的运行结果是()。includeint fun(int n);void main(){cout
假定a=3,下列程序的运行结果是( )。 #include<iostream.h> int fun(int n); void main() { cout<<"Please input a number:"; int a,result=0; cin>>a; result=fun(a); cout<<result<<end1; } int fun(int n) { int p=1,result=0; for(int i=1;i<=n;i++) { p*=i; result +=p; } return result; }A.4B.8C.9D.20
考题
下列程序的执行结果是______。 k =0 For i=1 To 3 a = i ^ i ^ k Print a; Next IA. 1 1 1B.1 2 3C.0 0 0D.1 4 9
考题
以下程序输出结果是 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
考题
( 17 )下列程序的输出结果是public class Test{public static void main(String[] args){int [] array={2,4,6,8,10};int size=6;int result=-1;try{for{int i=0;isize result==-1;i++}if(array[i]==20) result=i;}catch(ArithmeticException e){System.out.println( " Catch---1 " );catch(ArrayIndexOutOfBoundsException e){System.out.println( " Catch---2 " );catch(Exception e){System.out.println( " Catch---3 " );}}A ) Catch---1B ) Catch---2C ) Catch---3D )以上都不对
考题
for (int i =0; i 4; i +=2) { System.out.print(i + “”); } System.out.println(i); What is the result?() A、 0 2 4B、 0 2 4 5C、 0 1 2 3 4D、 Compilation fails.E、 An exception is thrown at runtime.
考题
单选题for (int i =0; i 4; i +=2) { System.out.print(i + “”); } System.out.println(i); What is the result?()A
0 2 4B
0 2 4 5C
0 1 2 3 4D
Compilation fails.E
An exception is thrown at runtime.
考题
单选题class super ( public int I = 0; public super (string text) ( I = 1 ) ) public class sub extends super ( public sub (string text) ( i= 2 ) public static void main (straing args) ( sub sub = new sub (“Hello”); system.out. PrintIn(sub.i); ) ) What is the result?()A
Compilation will fail.B
Compilation will succeed and the program will print “0”C
Compilation will succeed and the program will print “1”D
Compilation will succeed and the program will print “2”
考题
单选题class Computation extends Thread { private int num; private boolean isComplete; private int result; public Computation(int num) { this.num = num; } public synchronized void run() { result = num * 2; isComplete = true; notify(); } public synchronized int getResult() { while (!isComplete) { try { wait(); } catch (InterruptedException e) { } } return result; } public static void main(String[] args) { Computation[] computations = new Computation [4]; for (int i = 0; i computations.length; i++) { computations[i] = new Computation(i); computations[i] .start(); } for (Computation c : computations) System.out.print(c.getResult() +“ “); } } What is the result?()A
The code will deadlock.B
The code may run with no output.C
An exception is thrown at runtime.D
The code may run with output “0 6”.E
The code may run with output “2 0 6 4‟.F
The code may ruin with output “0 2 4 6”.
热门标签
最新试卷