2-C++期末考试试题及答案 

loading 分享 2026-8-28 下载文档

void print(){for(int i=0; i Stack::Stack(){ for(int i=0; i bool Stack::push(T x){ if(iCurrentElem==(size-1)) {cout<<\

else {s[++iCurrentElem]=x; return true;} } template T Stack::pop(){ T temp; if(iCurrentElem==-1) {cout<<\ else {temp=s[iCurrentElem];s[iCurrentElem]=0; iCurrentElem--; return temp;} } void main() {

float t; Stack s1; s1.push(10); s1.push(20); s1.push(30); s1.push(40); s1.print(); t=s1.pop(); s1.print(); cout<

} 5.(2真的不掉线吗??、???????????? 5分) 用C++语言定义MyString(包括成员函数的实现代码),使之能符合下面程序及在注释中描述的运行结果的要求: main() { MyString s1 = \ s1.display(); // 此时显示出: <0123456789> s2.display(); // 此时显示出(<>之间是五个空格): < >

s3.display(); // 此时显示出: <> s4.display(); // 此时显示出: <0123456789> s3 = s1; s3.display(); // s3 = 3+s3; s3.display(); // s2 = s1[2]; s2.display(); // s1.display(); // s3 = s2++; 此时显示出: <0123456789> 此时显示出: <0123456789999> 此时显示出: <23456789> 此时显示出: <0123456789>


2-C++期末考试试题及答案 .doc 将本文的Word文档下载到电脑
搜索更多关于: 2-C++期末考试试题及答案  的文档
相关推荐
相关阅读