题目内容

【说明】 以下程序的功能是设计一个栈类stack<T>,并建立一个整数栈。 【程序】 #include < iostream. h > #include < stdlib. h > const int Max =20; //栈大小 template < class T > class stack{ //栈元素数组 T s[Max]; //栈顶下标 int top; public: stack( ) { top =-1; //栈顶初始化为-1 } void push( const T &item); //item入栈 T pop( ); //出栈 int stackempty( ) const; //判断栈是否为 }; template < class T > void stack <T >::push(const T &item) { if(top== (1) ) { cout <<"栈满溢出" <<endl; exit(1); } top ++ s[top] = item; } template < class T > T stack<T> ::pop() { T temp; if(top== (2) ) { cout <<"栈为空,不能出栈操作" < < endl; exit(1); } temp =s[top]; top --; return temp; } template < class T > int stack < T >:: stackempty( ) const { return top == -1; { void main( ) { stack <int> st; int a[] ={1,2,3,4,5}; cout <<"整数栈" <<endl; cout <<"入栈序列:" <<endl; for(int i=0;i<4;i ++) { cout <<a[i] <<" "; (3) ; } cout << endl <<"出栈序列"; while( (4) ) tout<< (5) <<" "; cout< < endl; }

查看答案
更多问题

在领导绩效考评中,坚持客观公正原则应做到哪几点

[A] leg[B] foot[C] face[D] eye[E] nose[F] mouth[G] arm It’s the part of the body used to stand on and walk on.

委托调查是指通过互联网等媒介搜寻有价值的资料并展开调查。( )

A. 对
B. 错

Christmas is coming. It is celebrated(庆祝) every year on December 25 and it is the most celebrated holiday in the world. It is celebrated in Europe, North America, South America and in every country that has been touched by western culture. Christmas celebrates the birth of Jesus Christ. Today, most people who celebrate Christmas are not Christians(基督徒). They celebrate the holiday because Christmas is an opportunity for people to show the "good feelings" they have for each other. Christmas is called "the season of giving". It is the time of year when people give gifts to others to show how much they love them or just to show how much they appreciate(感激) them. We give gifts to our family and we also give gifts to close friends. Many people also give gifts to people who have performed services for them through the year, like the postman or the cleaner. And Christmas is the time of year we remember that many people are less fortunate than us: the poor, the sick and the lonely; and we try to help them in any way we can. Christmas is the time when we try our best to help the poor, the sick and the lonely.

A. Right.
B. Wrong.
C. Doesn’t say.

答案查题题库