有下列程序: include using namespace std; class Stack { public: Stack(unsigned 有下列程序: #include<iosteram.h> using namespace std; class Stack { public: Stack(unsignedn=10):size(n){rep_=new int [size];top=O;} Stack(Stacks):size(s.size) { rep_=new int[size]; foA.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,
有下列程序: include using namespace std; class Stack { public: Stack(unsigned
有下列程序: #include<iosteram.h> using namespace std; class Stack { public: Stack(unsignedn=10):size(n){rep_=new int [size];top=O;} Stack(Stack&s):size(s.size) { rep_=new int[size]; fo
A.4,3,2,1,
B.4,3,6,7,2,1,
C.4,3,6,2,1,
D.1,2,3,4,
相关考题:
重载操作符的定义一般见于 IEEE 库的哪几个程序包 A.std_logic_arith、std_logic_unsigned、std_logic_signedB.std_logic_arith、std_logic_unsigned、std_logic_1164C.std_logic_unsigned、std_logic_1164、std_logic_arithD.std_logic_1164、std_logic_arith、std_logic_unsigned、std_logic_signed
阅读以下说明C++代码,将应填入(n)处的字句写在对应栏内。[说明]以下程序的功能是实现堆栈的一些基本操作。堆栈类stack共有三个成员函数:empty判断堆栈是否为空;push进行人栈操作;pop进行出栈操作。[C++程序]include "stdafx. h"include <iostream, h>eonst int maxsize = 6;class stack {float data[ maxsize];int top;public:stuck(void);~ stack(void);bool empty(void);void push(float a);float pop(void);};stack: :stack(void){ top =0;cout < < "stack initialized." < < endl;}stack:: ~stack(void) {cout < <" stack destoryed." < < endl;bool stack:: empty (void) {return (1);void stack: :push(float a)if(top= =maxsize) {cout < < "Stack is full!" < < endl;return;data[top] =a;(2);}float stack:: pop (void){ if((3)){cout< < "Stack is undcrflow !" < < endl;return 0;(4);return (5);}void main( ){ stack s;coat < < "now push the data:";for(inti=l;i =maxsize;i+ +) {cout< <i< <" ";s. push(i);}coat < < endl;cout< < "now pop the data:";for(i = 1 ;i < = maxsize ;i + + )cout< <s. pop()< <" ";}
请将下列栈类Stack的横线处补充完整。class Stack{private:int pList[100]; ∥int数组,用于存放栈的元素int top; ∥栈顶元素(数组下标)public:Stack():top(0){}void Push(const int item); ∥新元素item
有如下程序:includeusing namespace std;classStack{public:Stack (unsigned n=10) 有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack (unsigned n=10):size (n) {rep_=new int [size]; top=0;} Stack (stacks}: size (s.size) { rep_new int[size]; for (int i=0;i<size;i++ rip_[i]-s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void poush (int a) {rep_[topj=a; top++;} int pep() { --top; return rep_[top];} bool isEmpty() cons5 [return Top ==0;} private: int*rep_; unsigned size, top; }; int main() { Stack s1; for(int i=1;i<5;i++) s1.push(i); Stack s2(s1); for(i=1;i<3;i++} cout<<s2.pop()<<','; s2.push(6); s1.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; } 执行上面程序的输出是A.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,
有下列程序: include using namespace std; class Base { public: Base(){cout 有下列程序: #include<iosteram.h> using namespace std; class Base { public: Base(){cout<<"BB"; f(); } void f(){cout<<"Bf";} }; class Derived:public Base { public: Derived(){cout<<"DA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
有如下程序:include using namespace std;class Stack {public: Stack(unsigned n= 1 有如下程序: #include <iostream> using namespace std; class Stack { public: Stack(unsigned n= 10):size(n) {rep_=ew int[size]; top=0;} Stack(Stack s):size(s.size) { rep_=new int[size]; for(int i=0;i<size;i++) rep_[i]=s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void push(int a) {rep_[top]=a; top++;} int pop() {--top;return rep_[top];} bool isEmpty() const {return top==0;} private: int *rep_; unsigned size,top; }; int main() { Stack s1; for(int i= 1;i<5 ;i++) s1. push(i); Stack s2(s1); for(i= 1 ;i3;i++) cout<<s2.pop()<<','; s2.push(6); si.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; }执行上面程序的输出是______ 。A.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,
有如下程序:include using namespace std;class Stack{public:Stack(unsigned n=10 有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack(unsigned n=10):size(n){rep_=new int [size]; top=0;} Stack(Stacks): size (s.size) { rep_=new int[size]; for (int i=0;i<size;i++) rep_[i]=s.rep_[i]; top=s.top; } ~Stack(){delete[]rep_;} void push(int a){rep_[top]=a; top++;} int pop(){--top; return rep_[top];} bool isEmpty() const {return top ==0;} private: int*rep_; unsigned size, top; }; int main() { Stack s1; for(int i=1;i<5;i++) sl.push(i); Stack s2(s1); for (int i=1;i<3;i++) cout<<s2.pop()<<','; s2.push(6); s1.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; } 执行上面程序将输出( )。A.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,
阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。【C++代码】#include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}
开始往输入串末尾和分析栈stack中放“#”,然后把文法开始符号压栈。预测分析程序总是按_________和________。A.stack栈顶符号X 最后的输入符号bB.stack栈顶符号X 当前输入符号aC.stack栈尾符号X 当前输入符号aD.stack栈尾符号X 最后的输入符号b