niusouti.com

下面语句中是堆桔段定义的语句是()。A、CODE SEGMENTB、DATA SEGMENTC、STACK SEGMENT ‘STACK’D、MAIN PROC FAR

题目

下面语句中是堆桔段定义的语句是()。

  • A、CODE SEGMENT
  • B、DATA SEGMENT
  • C、STACK SEGMENT ‘STACK’
  • D、MAIN PROC FAR

相似考题

4.使用VC6打开考生文件夹下的工程test34_3。此工程包含一个test34_3.cpp,其中定义了表示栈的类stack。源程序中stack类的定义并不完整,请按要求完成下列操作,将程序补充完整。(1)定义类stack的私有数据成员sp和size,它们分别为整型的指针和变量,其中sP指向存放栈的数据元素的数组,size为栈中存放最后一个元素的下标值。请在注释“//**1**”之后添加适当的语句。(2)完成类stack的构造函数,该函数首先从动态存储空间分配含有100个元素的int型数组,并把该数组的首元素地址赋给指针sp,然后将该数组的所有元素赋值为0,并将size赋值为-1(size等于-1表示栈为空)。请在注释“//**2**”之后添加适当的语句。(3)完成类stack的成员函数push的定义。该函数将传入的整型参数x压入栈中,即在size小于数组的最大下标情况下, size自加1,再给x赋值。请在注释“//**3**”之后添加适当的语句。(4)完成类stack的成员函数pop的定义,该函数返回栈顶元素的值,即在size不等于-1的情况下,返回数组中下标为size的元素的值,并将size减1。请在注释“//**4**”之后添加适当的语句。程序输出结果如下:the top elem:1the pop elem:1the stack is empty注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test34_3.cpp清单如下:include<iostream.h>class stack{//** 1 **public:stack ( );bool empty(){return size==-1;}bool full() {return size==99;}void push(int x);void pop();void top();};stack::stack(){//** 2 **for(int i=0; i<100; i++)*(sp+i)=0;size=-1;}void stack::push(int x){//** 3 **cout<<"the stack is full"<<end1;else{size++;*(sp+size) = x;}}void stack::pop(){//** 4 **cout<<"the stack is empty"<<end1;else{cout<<"the pop elem:"<<*(sp+size)<<end1;size--;}}void stack::top(){if iempty() )cout<<"the stack is empty"<<end1;else{cout<<"the top elem:"<<*(sp+size)<<end1;}}void main ( ){stack s;s.push(1);s.top();s.pop();s.top();}

更多“下面语句中是堆桔段定义的语句是()。A、CODE SEGMENTB、DATA SEGMENTC、STACK SEGMENT ‘STACK’D、MAIN PROC FAR”相关问题
  • 第1题:

    下述程序为一数据段,正确的判断是( )。 DATA SEGMENT X DB 332H FIRST = 1 FIRST EQU 2 ENDS

    A.以上5条语句为代码段定义,是正确的

    B.语句3、4分别为FIRST赋值,是正确的

    C.语句2定义变量X是正确的

    D.以上没有正确答案


    正确答案:D
    解析:该程序段为数据段定义,段结束指令ENDS前无段名是错误的:332H超过了字节表示的范围,所以变量x的定义也不正确;语句4中符号FIRST已经定义过,所以也是错误的。

  • 第2题:

    以下程序实现栈的入栈和出栈的操作。其中有两个类:一个是节点类node,它包含点值和指向上一个节点的指针 prev;另一个类是栈类 stack, 它包含栈的头指针 top。

    生成的链式栈如下图所示。

    〈IMG nClick=over(this) title=放大 src="tp/jsj/2jc++j28.1.gif"〉

    下面是实现程序,请填空完成此程序。

    include 〈iostream〉

    using namespace std;

    class stack;

    class node

    {

    int data;

    node *prev;

    public:

    node(int d, node *n)

    {

    data=d;

    prev=n;

    }

    friend class stack;

    };

    class stack

    {

    node *top; //栈头

    public:

    stack()

    {

    top=0;

    }

    void push(int i)

    {

    node *n=【 】;

    top=n;

    }

    int pop()

    {

    node *t=top;

    if (top)

    {

    top=top-〉prev;

    int c= t-〉data;

    delete t;

    return c;

    }

    return 0;

    }

    int main ()

    {

    stack s;

    s.push(6);

    s.push(3);

    s.push (1);

    return 0;

    }


    正确答案:new node(itop)
    new node(i,top) 解析:本题考核友元类以及对象成员的应用,属于综合考题。本程序中定义了两个类node和stack,用于实现堆栈的压入和弹出操作。其中,类 stack是类node的友元类,这样类stack中的成员可以访问类node中的所有成员。在类node中,定义两个私有变量:整型变量data和对象指针prev。变量data用于保存节点的数值,而对象指针prey用于指向上一节点。在类node的构造函数中,形参是数据d和对象指针n。在类stack中,定义了一个私有变量,栈顶指针top,并在构造函数中赋值0(即指针为空)。
    函数push()实现入栈操作,即把形参i压入栈中,那么此时应该创建一个新的节点,并让这个节点的prev指针指向栈顶,即top。然后让top指针指向新的节点。所以在push()函数中应填入“node*n=new node(i,top)”。类stack中的pop()函数实现数据的弹出功能。先定义了一个对象指针t指向栈顶节点。然后判断堆栈是否为空,如果为空,则返回0,否则就弹出栈顶节点的值。那么应该先将栈顶指针后退一个节点,然后把对象t指针指向的节点值弹出,并删除节点t。

  • 第3题:

    下面是一个栈类的模板,其中push函数将元素i压入栈顶,pop函数弹出栈顶元素。栈初始为空,top值为0,栈顶元素在stack[top-1]中,在下面横线处填上适当的语句,完成栈类模板的定义。

    template<class t>

    class Tstack

    {

    enum{size=1000};

    T stack[size]

    int top;

    public:

    Tsack():top(0){}

    void push(const T&i){

    if(top<size)

    stack[top++]=i;

    }

    T pop()

    {

    if(top==O)exit(1);//栈空时终止运行

    retum【 】;

    }

    };


    正确答案:stack[--top]
    stack[--top] 解析:++/--运算符;注意栈顶元素在stack[top-1]中。

  • 第4题:

    被连接的汇编语言程序模块中,下面( )分段定义伪指令语句所使用组合类型是不可设为默认的。

    A.PUBLIC

    B.COMMON

    C.MEMORY

    D.STACK


    正确答案:D

  • 第5题:

    ●The principle for a stack memory to store data is () 。()A. FIFO B. FILO C. random D. other way


    正确答案:B
    栈存储数据的原则是。。。

  • 第6题:

    下面语句中,是伪指令语句的有()。

    • A、CMP AX,CX
    • B、DB?
    • C、IDIV CX
    • D、ORG 30H
    • E、DATA SEGMENT

    正确答案:B,D,E

  • 第7题:

    下列选项中是用来定义结构体的关键字是()。

    • A、struct
    • B、function
    • C、static
    • D、stack

    正确答案:A

  • 第8题:

    数组元素所占用的内存位于()  

    • A、数据区(Data)
    • B、代码区(Code)
    • C、堆(Heap)
    • D、堆栈(Stack)

    正确答案:C

  • 第9题:

    单选题
    Multi Protocol Label Switching (MPLS) is a data-carrying mechanism that belongs to the family of packet-switched networks. For an MPLS label, if the stack bit is set to1, which option is true?()
    A

    The stack bit will only be used when LDP is the label distribution protocol

    B

    The label is the last entry in the label stack.

    C

    The stack bit is for Cisco implementations exclusively and will only be used when TDP is the label distribution protocol.

    D

    The stack bit is reserved for future use.


    正确答案: B
    解析: 暂无解析

  • 第10题:

    单选题
    下面语句中是堆梳段定义的语句是()
    A

    CODE SEGMENT

    B

    DATA SEGME~T

    C

    STACK SEGMENT ‘STACK’

    D

    MAIN PROCFAR


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    若程序中对堆栈设置如下,则下列说法错误的是()。 size   .set    120 stack  .usect  “STACK”,size                STM     # stack + size,SP
    A

    此堆栈段的段名为STACK

    B

    此堆栈段共120个单元

    C

    此堆栈段第一个变量的名称为size

    D

    堆栈设置好后,堆栈指针SP指向栈底


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    数组元素所占用的内存位于()
    A

    数据区(Data)

    B

    代码区(Code)

    C

    堆(Heap)

    D

    堆栈(Stack)


    正确答案: A
    解析: 暂无解析

  • 第13题:

    The principle for a stack memory to store data is

    A.FIFO

    B.FILO

    C.random

    D.other way


    正确答案:B

  • 第14题:

    在段定义伪指令语句中,下列哪一种组合类型是不可缺省的?

    A.PUBLIC

    B.COMMON

    C.MEMORY

    D.STACK


    正确答案:D

  • 第15题:

    使用VC6打开考生文件夹下的工程MyProj8。此工程包含一个源程序文件MyMain8.cpp,该程序实现栈的入栈和出栈的操作。其中有两个类:一个是节点类node,它包含节点值和指向上一个节点的指针prey;另一个类是栈类stack,它包含栈的头指针top。但类的定义并不完整。

    请按要求完成下列操作,将类Sample的定义补充完成:

    ①定义私有节点值data,它是血型的数据,以及定义一个指向上一个节点的指针prev。请在注释“//* *1* *”之后添加适当的语句。

    ②完成构造函数node(int d,node*n)的定义,使得私有成员data和prev分别初始化为d和n。请在注释“//* *2* *”之后添加适当的语句。

    ③完成类stack的成员函数push(int i)的类体内的定义。函数push()实现入栈这个操作,即把形参i压入栈中,那么此时应该创建一个新的节点,并让这个节点的prev指针指向栈顶。请在注释“//* *3 * *”之后添加适当的语句。

    注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。

    源程序文件MyMain8.cpp清单如下:

    //MyMain 8.cpp

    include <iostream>

    using namespace std;

    class stack;

    class node

    {

    private:

    //* * 1 * *

    public:

    node(int d, node *n)

    {

    //* * 2 * *

    }

    friend class stack;

    };

    class stack

    {

    node *top; //栈头

    public:

    stack()

    {

    top=0;

    }

    void push(int i)

    {

    //* * 3 * *

    }

    int pop()

    {

    node*t=top;

    if(top)

    {

    top=top->prev;

    int c=t->data;

    delete t;

    return c;

    }

    return 0;

    }

    };

    int main()

    {

    stack s;

    s.push(6);

    s.push(3);

    s.push(1);

    return 0;

    }


    正确答案:

  • 第16题:

    下述程序为一数据段,正确的判断的是( )。 DATA SEGMENT X DB 332H FIRST=1 FIRST EQU2 ENDS

    A.以上5条语句为代码段定义,是正确的

    B.语句3,4分别为FIRST赋值,是正确的

    C.语句2定义变量X是正确的

    D.以上没有正确的答案


    正确答案:D

  • 第17题:

    下面语句中是堆梳段定义的语句是()

    • A、CODE SEGMENT
    • B、DATA SEGME~T
    • C、STACK SEGMENT ‘STACK’
    • D、MAIN PROCFAR

    正确答案:C

  • 第18题:

    子程序是用过程定义语句()定义的。

    • A、PROC    ENDP
    • B、PROC    ENDS
    • C、CALL    RET
    • D、PROC    RET

    正确答案:A

  • 第19题:

    Multi Protocol Label Switching (MPLS) is a data-carrying mechanism that belongs to the family of packet-switched networks. For an MPLS label, if the stack bit is set to1, which option is true?()

    • A、The stack bit will only be used when LDP is the label distribution protocol
    • B、The label is the last entry in the label stack.
    • C、The stack bit is for Cisco implementations exclusively and will only be used when TDP is the label distribution protocol.
    • D、The stack bit is reserved for future use.

    正确答案:B

  • 第20题:

    You are creating an undo buffer that stores data modifications.You need to ensure that the undo functionality undoes the most recent data modifications first.You also need to ensure that the undo buffer permits the storage of strings only.Which code segment should you use?()

    • A、Stack<string> undoBuffer=new Stack<string>();
    • B、Stack undoBuffer=new Stack();
    • C、Queue<string> undoBuffer=new Queue<string>();
    • D、Queue undoBuffer=new Queue();

    正确答案:A

  • 第21题:

    单选题
    下面语句中是堆桔段定义的语句是()。
    A

    CODE SEGMENT

    B

    DATA SEGMENT

    C

    STACK SEGMENT ‘STACK’

    D

    MAIN PROC FAR


    正确答案: D
    解析: 暂无解析

  • 第22题:

    多选题
    下面语句中,是伪指令语句的有()。
    A

    CMP AX,CX

    B

    DB?

    C

    IDIV CX

    D

    ORG 30H

    E

    DATA SEGMENT


    正确答案: C,A
    解析: 暂无解析

  • 第23题:

    单选题
    You are creating an undo buffer that stores data modifications.You need to ensure that the undo functionality undoes the most recent data modifications first.You also need to ensure that the undo buffer permits the storage of strings only.Which code segment should you use?()
    A

    Stack<string> undoBuffer=new Stack<string>();

    B

    Stack undoBuffer=new Stack();

    C

    Queue<string> undoBuffer=new Queue<string>();

    D

    Queue undoBuffer=new Queue();


    正确答案: A
    解析: 暂无解析