阅读下面求质数的程序 import java. lang. Math. * ; public class MorePrimesTest{ public static void main(String[]args){ long[]primes=new long[20]; primes[0]2L; primes[1]3L; long number=5L; outer: for(int count=2; count<primes. length; number+ =2L){ long limit=(long)Math. ceil(Math. sqrt((double)number)); for(int i=1; i<count && primes[i]<limit; i+ +){ if(number______primes[i]==0L){ cotinue outer; } } for(int j=0; j<primes. length; j ++){ long n=primes[j]; System. out. println(n); } } } 在程序下画线处填入的正确选项是
A.&
B.*
C./
D.%
第1题:
下面程序的结果是 #include<iostream.h> class A { int a; public: A( ):a(1){} void showa( ){cout<<a;} }; class B { int a; public: B( ) :a(2) {}
A.1
B.2
C.3
D.程序有错误
第2题:
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }
A.CBA
B.ABC
C.ACB
D.BCA
第3题:
第4题:
阅读下面程序:
include <iostream.h>
template <class T>
class TAdd
{
private:
T x, y;
public:
TAdd(T a, T b)
{
x=a;
y=b;
}
T add()
{
return x +y;
}
};
void main( )
{
TAdd<int>a(5,6);
TAdd<double>b(2.4,5.8);
cout<<"s1 ="<<A. add()<<",";
cout<<"s2="<<B, add()<<end1;
}
写出该程序的运行结果:【 】。
第5题:
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
A.new file open file save file
B.new file new file new file
C.编译出错
D.open file new file save file
第6题:
阅读下面的程序, 写出运行后输出的结果。 #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B :public A { public: B(){cout<<"B";} }; void main() { B b1; }