A、with an angry expression
B、unexpectedlywithout warning
C、thinking deeply
D、extremely pleased
第1题:
编写函数,isValue,它的功能是:求以下数列中满足t(K)=1的最小的k,结果由函数返回。其中数列t(n)的定义为:
t(0)=m(m为给定正整数,m<=300)
t(n+1)=t(n)/2 (当t(n)为偶数时)
或t(n+1)=3*t(n)+1(当t(n)为奇数时)
最后调用函数writeDat()读取50个数据m,分别得出结果且把结果输出到文件out.dar中。
例如:当t=299时,函数值为117。
已知对于m<=300,结果k不超过300
部分源程序已给出。
请勿改动主函数main()和写函数writeDat()的内容。
include<stdio. h>
int jsValue(int m)
{
main ( )
{
int m;
m=300;
printf ("m=%d, k-%d\n", m, jsValue (m));
writeDat ( );
writeDat ( )
{
FILE *in, *out;
int i,m,s;
in= fopen ( "in. dar" , "r" );
ut=f open ( "out. dar" , "w" );
for (i=0; i<50; i++) {
fscanf (in, "%d", &m);
s=jsValue (m);
printf( "%d\n", s );
fprintf (out, "%d\n" , s );
}
fclose (in);
fclose (out);
第2题:
publicclassWow{publicstaticvoidgo(shortn){System.out.println(”short”);}publicstaticvoidgo(Shortn){System.out.println(”SHORT”);}publicstaticvoidgo(Longn){System.out.println(”LONG”);}publicstaticvoidmain(String[]args){Shorty=6;intz=7;go(y);go(z);}}Whatistheresult?()
A.shortLONG
B.SHORTLONG
C.Compilationfails.
D.Anexceptionisthrownatruntime.
第3题:
请阅读下面程序 publicclassThreadTest{ publicstaticvoidmain(Stringargs[])throwsException{ inti=0; Hellot=newHello(); ______, while(true){ System.out.println("GoodMoming"+i++); if(i==2&&t.isAlive()){ System.out.println("MainwaitingforHello!"); t.join();//等待t运行结束 } if(i==5)break;} } } classHelloextendsThread{ inti; publicvoidrun(){ while(true){ System.out.println("Hello"+i++); if(i==5)break;}}} 为使该程序正确执行, 下划线处的语句应是( )。
A.t.sleep()
B.t.yield()
C.t.interrupt()
D.t.start()
第4题:
publicclassTestOneimplementsRunnable{publicstaticvoidmain(String[]args)throwsException{Threadt=newThread(newTestOne());t.start();System.out.print(”Started”);t.join();System.out.print(”Complete”);}publicvoidrun(){for(inti=0;i<4;i++){System.out.print(i);}}}Whatcanbearesult?()
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesandprints“StartedComplete”.
D.Thecodeexecutesandprints“StartedComplete0123”.
E.Thecodeexecutesandprints“Started0l23Complete”.
第5题:
publicclassYikes{publicstaticvoidgo(Longn){System.out.println(”Long);}publicstaticvoidgo(Shortn){System.out.println(”Short);}publicstaticvoidgo(intn){System.out.println(”int);}publicstaticvoidmain(String[]args){shorty=6;longz=7;go(y);go(z);}}Whatistheresult?()
A.intLong
B.ShortLong
C.Compilationfails.
D.Anexceptionisthrownatruntime.
第6题:
已知s0=8,则表达式out = s0 ? i1 : i2的结果是 。
A.out=i1
B.out=i2
C.out=1
D.out=0