更多"请将下列栈类Stack补充完整。
class Stack{
"的相关试题:
[填空题]请将下列栈类Stack补充完整
class Stack{
private:
int pList[100]; //int数组,用于存放栈的元素
int top; //栈顶元素(数组下标)
public:
Stack( ):top(0){}
void Push(const int &item);//新元素item压入栈
int Pop(void); //将栈顶元素弹出栈
};
void Stack::Push(const int &item){
if(top==99) //如果栈满,程序终止
exit(1);
top++; //栈顶指针增1
【15】 ;
}
int Stack::Pop( ){
if(top<0) //如果栈空,程序终止
exit(1);
return pList[top--];
}
[填空题]请将下列栈类Stack补充完整。
class Stack
private:
intpList[100]//int数组,用于存放栈的元素
inttop;//栈顶元素(数组下标)
public:
Stack( );top(0)
void Push(const int &item);//新元素item压入栈
int Pop(void); //将栈顶元素弹出栈
;
void Stack::Push(const int&item)
if(top==99) //如果栈满,程序终止
exit(1)
top++; //栈顶指针增1
______;
int Stack::Pop( )
if(top(0) 如果栈空,程序终止
exit(1);
return pList[top--];
[填空题]请将下列栈类Stack补充完整。
class Stack
private:
int pList[100]; //int数组,用于存储占的元素
int top; //栈顶元素(数组下标)
public:
Stack( ):top(0)
void Push(const int&item); //新元素item压入栈
int Pop(void); //将栈顶元素弹出栈
;
void Stack::Push(const int&item)
if(top==99) exit(1); //如果栈满,则程序终止
top++; //栈顶指针增1
______;
int Stack::Pop( )
if(top<0) exit(1); //如果栈空,则程序终止
return Plist[top--];
[填空题]请将下列栈类Stack的横线处补充完整。
class Stack
private:
int pList[100]; ∥int数组,用于存放栈的元素
int top; ∥栈顶元素(数组下标)
public:
Stack( ):top(0)
void Push(const int &item); ∥新元素item压入栈
int Pop(void); ∥将栈顶元素弹出栈
;
void Stack∷Push(const int &item)
if(top==99) ∥如果栈满,程序终止
exit(1);
top++; ∥栈顶指针增1
______;
int Stack∷Pop( )
if(top<0) ∥如果栈空,程序终止
exit(1);
return pList[top--];
[填空题]
请将下面程序补充完整。
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 【11】 (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;
}
}
[填空题]类Sampie的构造函数将形参data赋值给数据成员data。请将类定义补充完整。
class Sample
public:
Sample(int data=0);
priVate:
int data:
;
Sample::Sample(int datA)
______
[填空题]
类Sample的构造函数将形参data赋值给数据成员data。请将类定义补充完整。
class Sample{
public:
Sample(int data=0);
Private:
Int data;
};
Sample::Sample(int data){
【10】
}
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame {
public static void main(String args[]){
FirstFrame fr=new FirstFrame("First container!");
fr.setSize(240,240);
fr. setBackground(Color.yellow);
【15】
}
public FirstFrame(String str){
super(str);
}
}
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame
public static void main(String args[])
FirstFrame fr=new FirstFrame("First container!");
fr.setSize(240,240);
fr.setBackground(Color.yellow);
【15】
public FirstFrame(Strings str)
super[str);
)
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame
public static void main(String args[])
FirstFrame fr = new FirstFrame("First container!");
fr. setSize(240,240);
fr. setB ackground(Color, yellow);
【15】
public FirstFrame(String str)
super(str);
[填空题]
请将下列模板类Data补充完整。
template
class Data{
public:
void put (T v) { val=v; }
【15】 get( ) //返回数据成员val的值,返回类型不加转换
{ return val; }
private:
T val;
};
[填空题]请将下列类定义补充完整
class Base{public: void fun( ){cout<<"Base::fun"<<end1;}};
class Derived:public Base
{
public:
void fun( ){
______//显式调用基类的fun函数
cout<<"Derived::fun"<<end1;
}
};
[填空题]请将下列类定义补充完整。
class Basepublic:void fun( )cout<<"Base∷fun"<<end1;;
c1ass DehVed:public Base
public:
void fun( )
______ ∥显式调用基类的fun函数
cout<<"Derived∷fun"<<endl;
;
[填空题]请将下列模板类Data补充完整。
template <typename T>
class Data
public:
void put(T v)val=v;
______get( )return val; //返回数据成员val的值,返回类型不加转换
private:
T val;
;
[填空题]下列程序的输出结果为2,请将程序补充完整。
using namespace std;
class Base
public:
【12】 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’;