有如下程序: #nclude<iostremn> using namespace std; class Stack{ public: Stack(unsigned n=10:size(n){rep_=new int[size];top=O;} 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 opo(){--top;return rep_[top];} bool is Empty()const{return top==O;} pavate: 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
第1题:
有如下程序: #include <iostream> void fun(int& x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是
A.42,42
B.23,23
C.23,42
D.42,23
第2题:
有如下程序: #inchde<iostream.h> void fun(int &x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42); fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<Std::endl; return 0; } 执行后的输出结果是( )。
A.42,42
B.23,23
C.23,42
D.42,23
第3题:
第4题:
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第5题:
实现动态分配对象列表的类是( )。
A.System类
B.Class类
C.Vector类
D.Stack类