int x = 3; int y = 1; if (x = y) { System.out.println(“x = “ + x); } What is the result? ()
第1题:
以下数组定义中错误的是
A.int x[][3]={0};
B.int x[2][3]={{l,2},{3,4},{5,6}};
C.int x[][3]={{l,2,3},{4,5,6}};
D.int x[2][3]={l,2,3,4,5,6};
第2题:
A.x := []int{1, 2, 3,4, 5, 6,}
B.x := []int{1, 2, 3,4, 5, 6}
C.x := []int{1, 2, 3,4, 5, 6}
D.x := []int{1, 2, 3, 4, 5, 6,}
第3题:
下面程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int a) { int c; C=X*a; retum c; } void main() { int x=3,a=4; x=x+fun(a); cout<<"x"”<<X<<endl; }
A.x=15
B.x=17
C.x=23
D.x=25
第4题:
下列程序执行后,屏幕的输出是( )。 #include<iostream> using namespace std; void swap(int x,int y) { int temp=x; x=y; y=temp; cout<<"x="<<x<<"",y=""<<y<<end1; } int main() { int x=3,y=2; swap(x,y); cout<<"x="<<x<<",y="<<y<<end1; return 0; }
A.x=3,y=2 x=3,y=2
B.x=2,y=3 x=3,y=2
C.x=2,y=3 x=2,y=3
D. x=3,y=2 x=2,y=3
第5题:
下列程序的输出结果是( )。
#include<stdio.h>
int fun(int x)
{ int a;
if(x==0‖x==1)
return 3;
else
a=x-fun(x-2) ;
return a;
}
void main()
{ printf("%d",fun(7) );
}
A.2
B.8
C.9
D.5
第6题:
有以下程序 #include<stdio.h> void fun(int*a,int*B) { int*c; c=a;a=b;b=c; } main() { int x=3, y=5,*p=&x, *q=&y; fun(p,q); printf("%d,%d,",*p,*q); fun(&x,&y); printf(" %d,%d\n",*p,*q); } 程序运行后的输出结果是______。
A.3,5,5,3
B.3,5,3,5
C.5,3,3,5
D.5,3,5,3
第7题:
有下列程序: #include <stdio.h> int f(int x) { int y; if(x=0‖x==1)return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3);printf("%d\n",z); 程序的运行结果是( )。
A.0
B.9
C.6
D.8
第8题:
下列程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int A) { int C; C=X*a; return C; } void main() { int x=3,a=4; x=x+fun(a); cout<<"x="<<x<<endl; }
A.x=15
B.x=17
C.x=23
D.x=25
第9题:
以下程序的输出的结果是 int x=3; main() { int i; for (i=1;i<x;i++) incre(); } incre() { staic int x=1; x*=x+1; printf(" %d",x); }
A.3 3
B.22
C.26
D.25
第10题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { print f("\n%d", fun(5)); }
A.5
B.3
C.7
D.1
第11题:
下列带缺省值参数的函数说明中,正确的说明是 ______。
A.int Fun(int x, int y=2,int z=3);
B.int Fun(int x=1,int y,int z=3);
C.int Fun(int x, int y=2,iht z);
D.int Fun(int x=1,int y, int z=3);
第12题:
Which two code fragments are most likely to cause a StackOverflowError?()
第13题:
下列程序的输出结果是( )。
#include<stdio.h>
voidp(int*x)
{printf("%d",++*x);
}
voidmain()
{int y=3;
p(&y);
}
A.3
B.4
C.2
D.5
第14题:
下面程序的结果【 】。
include<iostream.h>
int f(int);
void main() {
int x=1, i;
for (i=0; i<3; i++)
cout<<f(x)<<‘ ’ ;
cout<<end1;
}
int f(int x){
int y=1;
static int z=3
y++;
z++;
return (x+y+z);
}
第15题:
执行下列语句: #include<iostream> using namespace std; int main() { int x=3; if(x=5) cout<<x++<<end1; else cout<<x<<end1; return 0; } 程序的输出是( )。
A.3
B.4
C.5
D.6
第16题:
下面程序的运行结果是______。
include<iostream.h>
void fun(int &a,int b=3)
{
static int i=2;
a=a+b+i;
i=i+a;
}
void main()
{
int x=5,y=2;
fun(x,y);
cout<<x<<",";
fun(x);
cout<<x<<endl;
}
第17题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int a; if(x==0‖x==1) return 3; else a=x-fun(x-2); return a; } void main() { printf("%d",fun(7)); }
A.2
B.8
C.9
D.5
第18题:
以下程序的输出结果是int f(int x,int y){ return(y-x)*x; }main(){ int a=3,b=4,c=5,d; d=f(f(3,4),f(3,5)); printf("%d\n",d);}
第19题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { printf("\n%d",fun(5)); }
A.5
B.3
C.7
D.1
第20题:
下列程序的输出结果是( )。#include<stdio.h>int fun(int x){ int a; if(x==0||x=1) return 3; else a=x-fun(x-2); return a;}void main(){ printf("%d",fun(7));}
A.2
B.8
C.9
D.5
第21题:
以下程序的输出的结果是( )。#include <iostream.h>int x=3;void main(){ void incre(); int i; for (i=1;i<x;i++) incre();}Void incre(){ static int x=1; x*=x+1; cout<<x<<"";}
A.3 3
B.2 2
C.2 6
D.2 5
第22题:
在下面程序运行后,输出结果为 ______。 #include<iostream.h> void count(int x[],int n,int &y){ int k; y=0; for(k=0:k<n;k++) if(x[k]<0) y++; } void main(){ int b[]={2,1,-8,-3,7,2,4,6,0,-13}; int x; count(b,10,x); cout<<“x”<<x<<end1; }
A.x=3
B.x=5
C.出错
D.x=0
第23题:
设有如下类:
class MyPoint {
void myMethod() {
int x, y;
x = 5; y = 3;
System.out.print( " ( " + x + ", " + y + " ) " );
switchCoords( x, y );
System.out.print( " ( " + x + ", " + y + " ) " );
}
void switchCoords( int x, int y ) {
int temp;
temp = x;
x = y;
y = temp;
System.out.print( " ( " + x + ", " + y + " ) " );
}
}
如果执行myMethod()方法,则输出结果为?
A. (5, 3、(5, 3、(5, 3、
B. (5, 3、(3, 5、(3, 5、
C. (5, 3、(3, 5、(5, 3、
第24题:
int []x = {1,2,3,4,5};for(int y = 0; y < 6; y++) System.out.println(x[y]);
static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }
for(int y = 10; y < 10; y++)doStuff(y);
void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }
for(int x = 0; x < 1000000000; x++) doStuff(x);
void counter(int i) { counter(++i); }