成语| 古诗大全| 扒知识| 扒知识繁体

当前位置:首页 > 趣味生活

程序的运行结果是什么

Q1:下程序的运行结果是( ).

A
此题中y,z为静态变量,程序结束时才会释放内存。
第一次调用f1()时,x =a = 1,z = 3, y = 0,执行y++; z++;后y = 1,z = 4;所以返回x+y+z = 1 + 1 + 4 = 6.
第二次调用f1()时,x =a = 1,z = 4, y = 0,执行y++; z++;后y = 2,z = 5;所以返回x+y+z = 1 + 2 + 5 = 8.
第三次调用f1()时,x =a = 1,z = 5, y = 0,执行y++; z++;后y = 3,z = 6;所以返回x+y+z = 1 + 3 + 6 = 10.

Q2:1、下面的程序的运行结果是什么?( )

d接口不能有构造方法,抽象类可以有

WWw.bAzhiSHi.C!Om

Q3:程序怎么运行的,输出结果是什么?

第一次index = 0index++%4为0index =1、count = ++indexcount = 2index = 2 这里没有break;继续执行
count +=indexcount=2+2=4 第一次循环结束 index++index=3、第二次 index++%4为3index=4 输出count = 4第二次循环结束 index=5、第三次 index++%4 为1index=6count+=index count=4+6=10index=7、第四次同第二次index=9输出count 为10、第五次同第三次index=11 count为10+10=20
index = 13输出20
index = 15count=20+14=34、index = 17 输出 34、index =19 count=34+18=52、index = 21 输出 52循环结束
最终结果是
4、10、20
34、52、

Q4:下面程序的运行结果是 ?(要详细解释啊!!!)

结果时 28 70,所以D)正确,选D)。把缩进写好这代码是这样的:

main(){
intx,i;
for(i=1;i<=100;i++){
x=i;
if(++x%2==0)
if(++x%3==0)
if(++x%7==0)
printf("%3d",x);
}
return0;
}

可见意思是:从2到100间,从某个数开始连续的3个数符合最小能被2整除、中间的能被3整除、最大的能被7整除。输出最大的数。找出的第一个数是28,28能被7整除,27能被3整除,26能被2整除。找出的第2个数是70,70能被7整除,69能被3整除,68能被2整除。那3个if的条件实质是“与”的关系,所以写成一句if(++x%2==0 &&++x%3==0 &&++x%7==0)也是可以的。


WwW.B%aZhISHi.cOM

Q5:1. 下面程序运行后的结果是什么?该程序的功能是什么? Private Sub Commandl_Click() Dim x$,n% n=20

功能:将十进制20转换成二进制10100
结果应该是10100吧 这个我算不好的 呵呵 你应该是自考本科的吧 呵呵 祝你考试顺利手打

Q6:给出以下代码,请问该程序的运行结果是什么?

package pkg1;
public class Example1 implements Runnable {
private String who;
public Example1(String str) {
who = str;
}
public void run() {
while (true) {
System.out.println(who + "h");
}
}
public static void main(String args[]) {
Example1 ex1 = new Example1("1");
Example1 ex2 = new Example1("2");
Example1 ex3 = new Example1("3");
ex1.run();
ex2.run();
ex3.run();
}
}
运行结果全是1h
所以答案为B

猜你喜欢

更多