empty()的功能是:
A.测试变量是否为空
B.测试变量是否存在
C.测试常量是否为空
D.测试常量是否存在
- · 有3位网友选择 C,占比37.5%
- · 有2位网友选择 B,占比25%
- · 有2位网友选择 D,占比25%
- · 有1位网友选择 A,占比12.5%
A.测试变量是否为空
B.测试变量是否存在
C.测试常量是否为空
D.测试常量是否存在
B.将队列Q中的元素逆置
C.输出栈S中的元素
D.输出队列Q中的元素
简述以下算法的功能(栈和队列的元素类型均为int)。
void algo(Queue&Q)
{
Stack S;
int d;
IntStack(S);
While(!StackEmpty(S))
{
Pop(S,d);
EnQueue(Q,d);
}
}
(1)Q、Q1和Q2都是队列结构,设队列Q=(1,0,-5,2,-4,-6,9),其中1为队头元素,写出执行f31(&Q,&Q1,&Q2)之后队列Q、Q1和Q2的状态;
(2)简述算法f31的功能。
(注:InitQueue、EnQueue、DeQueue和QueueEmpty分别是队列初始化、入队、出队和判队空的操作)
void f31(Queue*Q,Queue*Q1,Queue*Q2){
int e;
InitQueue(Q1);
InitQueue(Q2);
while(!QueueEmpty(Q)){
e=DeQueue(Q);
if(e>=0)EnQueue(Q1,e);
else EnQueue(Q2,e);
}
}
阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
以下程序的功能是设计一个栈类stack,并建立一个整数栈。
【程序】
#include
#include
B.h>
const int Max=20;∥栈大小
template
class stack{∥栈元素数组
T s[Max];∥栈顶下标
int top;
public:
stack()
{
top=-1;∥栈顶初始化为-1
}
void push(const T &item);∥item入栈
T pop();∥出栈
int stackempty()const;∥判断栈是否为空
};
template
void stack::push(const T &item)
{
if(top== (1) )
{
cout$amp;exit (1) ;
}
top++;
s[top]=item;
}
template
T stack::pop()
{
T temp;
if(top== (2) )
{
cout$amp;exit (1) ;
}
temp=s[top];
top--;
return temp;
}
template
int stack::stackempty()const
{
return top==-1;
}
void main()
{
stackst;
int a[]={1,2,3,4,5 };
cout$amp;cout$amp;for(int i=0;i<4;i++)
{
cout$amp; (3) ;
}
cout$amp;while((4) )
cout$amp;cout$amp;}
【说明】已知类LinkedList表示列表类,该类具有4个方法:addElement()、lastElement()、numberOfElement()以及removeLastElement()。4个方法的含义分别如下。voidaddElement(Obect):在列表尾部添加一个对象。ObjectlastElement():返回列表尾部对象。intnumberOfElement():返回列表中对象的个数。voidremoveLastElement():删除列表尾部的对象。现需要借助LinkedList来实现一个Stack栈类,C++代码1和C++代码2分别采用继承和组合的方式来实现。【C++代码1】
【C++代码2】
【问题】若类LinkedList新增加了一个公有的方法removeElement(intindex),用于删除列表中第index个元素,则在用继承和组合两种实现栈类Stack的方式中,哪种方式下Stack对象可访问方法removeElement(intindex)?__(5)__(A.继承B.组合)
A、当Enabled属性为False时,不产生Timer事件
B、当Enabled属性为True时,不产生Tick事件
C、当Interval属性为False时,不产生Timer事件
D、当Interval属性为True时,不产生Timer事件
E、当Visible属性为False时,不产生Timer事件
F、当Visible属性为True时,不产生Timer事件
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!