网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请将下面程序补充完整。

public class PowerCalc{

public static void main(String[]args){

double x=5.0;

System. out. println(x+"to the power 4 is"+power(x, 4));

System. out. println("7. 5 to the power 5 is"+power(7.5, 5));

System. out. println("7.5 to the power 0 is"+power(7.5, 0));

System. out. println("10 to the power -2 is"+power(10, -2));

}

static double【 】 (double x, int n){

if(n>1)

return x * power(x, n-1);

else if(n<0)

return 1.0/power(x, -n);

else

return n==0 ? 1.0:x;

}

}


参考答案

更多 “ 请将下面程序补充完整。public class PowerCalc{public static void main(String[]args){double x=5.0;System. out. println(x+"to the power 4 is"+power(x, 4));System. out. println("7. 5 to the power 5 is"+power(7.5, 5));System. out. println("7.5 to the power 0 is"+power(7.5, 0));System. out. println("10 to the power -2 is"+power(10, -2));}static double【 】 (double x, int n){if(n>1)return x * power(x, n-1);else if(n<0)return 1.0/power(x, -n);elsereturn n==0 ? 1.0:x;}} ” 相关考题
考题 ( 14 )请将如下程序补充完整,使得输出结果为: bbaa#includeiostreamusing namespace std;class A{public:___________{cout"aa";}};class B:public A{public:~B(){cout"bb";}};int main(){B *p=new B;delete p;return 0;}

考题 下面程序的输出结果为:Base:: fun,请将程序补充完整。include class Base{public: 【】 下面程序的输出结果为:Base:: fun,请将程序补充完整。include <iostream.h>class Base{public:【 】 fun(){cout<<"Base::fun"<<end1:}class Derived : public Base{public:【 】 fun(){ cout<<"Derived::fun"<<end1; }};int main(){Base a,*pb;Derived b;pb = b;pb->fun();return 0;}

考题 下列程序的输出结果为2,请将程序补充完整。 include using namespace std; class Basc 下列程序的输出结果为2,请将程序补充完整。include<iostream>using namespace std;class Basc{public:【 】void fun(){cout<<1;}};class Dcrived:public Base{public:void fun(){cout<<2;}};int main(){Base*p=new Derived;p->fun();delete p;return 0;}

考题 请将如下程序补充完整,使得输出结果为:bbaa include using namespace std; class A { 请将如下程序补充完整,使得输出结果为:bbaainclude <iostream>using namespace std;class A {public:【 】{cout << "aa"; }};class B: public A{public:~B(){ cout << "bb"; }};int main () {B *p= new B;delete p;return 0;}

考题 请将下列程序的横线处补充完整,使得输出结果为bbaaincludeusing namespace std;class 请将下列程序的横线处补充完整,使得输出结果为bbaainclude<iostream>using namespace std;class A{public:______{cout<<"aa";}};class B:public A{public:~B(){cout<<"bb";}};int main(){B*p=new

考题 下列程序的输出结果为2,请将程序补充完整。 include using namespace std; class Base 下列程序的输出结果为2,请将程序补充完整。include<iostream>using namespace std;class Base{public:______void fun(){cout<<1;}};class Derived:public Base{public:void fun(){cout<<2;}};int main(){Base*p=new Derived;p->fur();delete p;return 0;}

考题 将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}

考题 请将如下程序补充完整,使得输出结果为:bbaa。 include using naluespace std; class 请将如下程序补充完整,使得输出结果为:bbaa。include<iostream>using naluespace std;class A{public:______{eout<<"aa";}};class B:public A{public:~B( ){eont<<"bb";}};int ulain( ){B*P=new B;delete P;return 0;}

考题 下列程序的输出结果为2,请将程序补充完整。 include using namespaee std; class B 下列程序的输出结果为2,请将程序补充完整。include <iostream>using namespaee std;class Base{public:______void fun( ){cout<<1;}};class Derived:public Base{public:void fun( ){cout<<2;}};int main( ){Base*P=new Derived:p->fun( );delete P;return 0;}

考题 阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。 【说明】 以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。 【Java代码】 interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}