有以下程序void f(int v,int w){int t;t=v;v=w;w=t;}main(){ int x=1,y=3, z=2;if(x>y)f(x, y);else if(y>z) f(y,z);elsef(x,z);printf("%d,%d,%d/n",x,y, z);}执行后输出结果是()。
A.1,2,3
B.3,1,2
C.1,3,2
D.2,3,1
A.1,2,3
B.3,1,2
C.1,3,2
D.2,3,1
A.ABCDEFG
B.CDG
C.abcdefgh
D.abCDefGh
A.2,-1
B.3,1
C.2,0
D.2,1
A.25
B.15
C.20
D.24
class A{
int x=100;
}
class B extends A{
int x=200;
void prt(){
System.out.println("SubClass: "+x);
System.out.println("SuperClass: "+super.x);
}
public static void main(String args[]){
new B().prt();
}
}
写出以下程序的运行结果。public class Test2 {public static void main(String args[ ]){int i,j;int a[]={17,91,65,35,28};for (i = 0; i < a.length-1; i++ ) {int k = i;for(j = i; j < a.length; j++ )if (a[j]>a[k] )k = j;int temp =a[i];a[i] = a[k];a[k] = temp;}for (i =0; i<a.length; i++ )System.out.print(a[i]+" ");System.out.println();} }
public class Class1
{
public static void main(String args[])
{
int n=6,sum=0;
for(int k=1;k<=n;k++)
{
if (n%k==0)
sum+=k;
}
System.out.println(sum);
}
}
A.4
B.5
C.3
D.6
写出下列程序的运行结果。
#include void Fun(){int num=20;cout<< "The Fun's num is"<< num<< endl;
}void main(){int num=10;cout<< "The main's num is "<< num<< endl;Fun();{int num=30;
cout<< "The Field's num is "<< num<< endl;}cout<< "The main's num is "<< num<< endl;}
A.100
B.200
C.程序错误
D.300
程序填空题:执行下面程序的输出结果为()。
#include
void main() {
int x=36,y=48,z;
do {z=x%y; x=y; y=z;} while(y>0); .
printf("x=%d/n",x);
}
以下程序的功能是求两个非0整数相除的商和余数。程序有几处错误,试找出它们加以修改,并上机验证修改结果。 #include "iostream" using namespace std; int main() {int x,y,r1,r2; cin>>x>>y; if(x=0||y=0) cout<<”input else { if(x> y) r1=x/y; r2=x%y; else r1=y/x; r2=y%x; } cout<<”商=> <<” 余数="”<"> < <endl; system("pause"); return 0;>