更多"请将下列栈类Stack补充完整。 class Stack pr"的相关试题:
[填空题]请将下列栈类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:
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:
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;
}
}
[填空题]下列的Java语句是把字符串“12345”转换为int型数据,请补充完整。
int x;
x= 【 】 ;
[填空题]下列的Java语句是把字符串“12345”转换为int型数据,请补充完整。
int x;
x= 【11】 ;
[填空题]类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】
}
[单项选择]能将程序补充完整的选项是
class Person
private int a;
public int change(int m)return m;
public class Teacher extends Person
public int b;
public static void main(String arg[])
Person p=new Person( );
Teacher t=new Teacher( );
int i;
____
A. i=m
B. i=b
C. i=p.a
D. i=p.change(50)
[单项选择]能将程序补充完整的选项是( )。
class Person
private int a;
public int change(int m)return m;
public class Teacher extends Person
public int b;
public static void main(String arg[])
Person P=new Person( );
Teacher t=new Teacher( );
int i;
________
A. i=m
B. i=b
C. i=P.a
D. i=P.change(50)
[填空题]函数fun的功能是将一个数字字符串转换为一个整数,请将函数补充完整。
int fun(char *str)
int num=0;
while(*str)
num*=10;
num+=______;
str++;
return num;