当前位置: 首页 > news >正文

杭州城乡建设网站网页版传奇世界之仗剑天涯h5

杭州城乡建设网站,网页版传奇世界之仗剑天涯h5,网站建设与实现 文献综述,网站建设外包兼职北邮22信通一枚~ 跟随课程进度每周更新数据结构与算法的代码和文章 持续关注作者 解锁更多邮苑信通专属代码~ 上一篇文章#xff1a; 北邮22信通#xff1a;#xff08;9#xff09;实验1 题目六#xff1a;模拟内存管理#xff08;搬运官方代码#xff09;_青…北邮22信通一枚~    跟随课程进度每周更新数据结构与算法的代码和文章  持续关注作者  解锁更多邮苑信通专属代码~ 上一篇文章 北邮22信通9实验1 题目六模拟内存管理搬运官方代码_青山如墨雨如画的博客-CSDN博客 下一篇文章 目录 3.2.1顺序栈 代码部分 运行结果 遇到问题 运行结果 3.2.2链式栈 代码部分 运行结果 ***闲话*** 老规矩书上干净完整代码拿去用 最近一直在忙感冒忙修电脑忙期中考试          有点断更 顺序栈里边两个栈共用一个存储空间的代码正在更新中  敬请期待 下面就是实现顺序栈和链式栈的代码其实原理都差不多甚至主函数都一样 对小编个人而言更喜欢用链表a 不想判断顺序栈可恶的开始终止位置 然后虚拟数据类型我写了一个student比较简单的数据类型嘞方便大家看 其他的想到啥再补充啥  有问题或者我写的有不对的地方欢迎评论区指正 ********** 3.2.1顺序栈 代码部分 #include iostream using namespace std; struct student {int ID;string name; }; ostream operator(ostream output, student stu) {output stu.ID stu.name;return output; } const int stacksize 1024; template class temp class seqstack { public:seqstack() { top -1; }void push(temp x);temp pop();temp gettop();bool empty() { return top -1 ? true : false; }//判断栈空时的条件top-1? private:temp data[stacksize];int top; };templateclass temp void seqstacktemp::push(temp x) {if (this-top stacksize - 1)throw上溢;this-top;this-data[this-top] x; }template class temp temp seqstacktemp::pop() {if (empty())throw下溢;this-top--;return this-data[this-top 1]; }templateclass temp temp seqstacktemp::gettop() {if (empty())throw下溢;return this-data[this-top]; } int main() {try{system(color 0A);student x[5] { {1,zhang},{2,wang},{3,li},{4,zhao},{5,meng} };seqstackstudent seq1;cout 显示栈内是否为空 endl;cout seq1.empty();cout endl endl;cout 数据传输中…… endl;for (int i 0; i 5; i)seq1.push(x[i]);cout 显示栈内是否为空 endl;cout seq1.empty();cout endl endl;student stutemp;for (int i 0; i 5; i){cout 出栈元素的信息: endl;stutemp seq1.pop();cout stutemp;cout endl;cout 此时栈顶元素信息: endl;stutemp seq1.gettop();cout stutemp;cout endl endl;}cout endl 现在重新判断栈是否为空: endl;cout seq1.empty();}catch (const char* a){cout a endl;}return 0; } 运行结果 遇到问题 发现没有执行程序第79、80行 原因catch到了const char*类型的异常程序终止运行。 需要注意的是一定要catch const char*不要catchstring否则你的程序跑不起来 我们把68行循环终止条件改成3 运行结果 3.2.2链式栈 代码部分 #include iostream using namespace std; struct student {int ID;string name; }; ostream operator(ostream output, student stu) {output stu.ID stu.name;return output; } template class temp struct node {temp data;nodetemp* next; };template class temp class linkstack { public:linkstack() { top NULL; }~linkstack();void push(temp x);temp pop();temp gettop();bool empty(){return top NULL ? true : false;} private:nodetemp* top; };template class temp void linkstacktemp::push(temp x) {nodetemp* p new nodetemp;p-data x;p-next this-top;this-top p; }templateclass temp temp linkstacktemp::pop() {if (empty())throw 下溢;temp x this-top-data;nodetemp* p this-top;this-top this-top-next;delete p;return x; }templateclass temp linkstacktemp::~linkstack() {while (this-top ! NULL){nodetemp* p this-top;this-top this-top-next;delete p;} }templateclass temp temp linkstacktemp::gettop() {if (empty())throw下溢;return this-top-data; } int main() {try{system(color 0A);student x[5] { {1,zhang},{2,wang},{3,li},{4,zhao},{5,meng} };linkstackstudent linklist1;cout 显示栈是否为空 endl;cout linklist1.empty();cout endl endl;cout 数据传输中…… endl;for (int i 0; i 5; i)linklist1.push(x[i]);cout 显示栈是否为空 endl;cout linklist1.empty();cout endl endl;student stutemp;for (int i 0; i 5; i){cout 出栈元素信息: endl;stutemp linklist1.pop();cout stutemp;cout endl;cout 此时栈顶元素信息: endl;stutemp linklist1.gettop();cout stutemp;cout endl endl;}cout 现在重新判断栈是否为空: endl;cout linklist1.empty();}catch (const char*a){cout a endl;}return 0; } 运行结果 将pop循环改成循环到3同理会显示最后一行“现在重新判断栈是否为:”
http://www.dnsts.com.cn/news/17725.html

相关文章:

  • 网站前端做报名框代码北京网站优化培训
  • 做网站需要注意的问题网页制作网站图片
  • 太原晋民网站建设公司在北京网站建设的岗位
  • html5个性个人网站湛江做网站建设
  • 搜索引擎对网站推广的作用交友软件网站建设
  • 外贸做编织袋常用网站公司企业邮箱怎么查询
  • 南宁企业网站设计公司雨花台网站建设
  • 牡丹江市建设局网站搜索引擎优化涉及到内容
  • 网站好友邀请链接生成 php做网站时尺寸多大
  • 本地网站开发环境搭建东莞商场
  • ps做网站对齐技巧无代码快速搭建网站
  • 免费的建站平台网站备案期间可以建站
  • 领地网怎么编辑个人网站做网站对象存储
  • 静态网站更新菜谱设计制作图片
  • 怎么才能搜索到自己做的网站淘宝网首页登录网页版
  • 如何网站做外贸生意网络服务费的资金产出有哪些
  • 上海做网站设计阿里巴巴官网电脑版登录入口
  • 直播网站开发计划书京山大洪山旅游开发有限公司 做网站
  • 创新的福州网站建设项目立项流程图
  • 北京建设商业网站河南省新闻联播视频
  • 哪里可以找人做网站wordpress 女装小说
  • 企业网站优化费用著名食品包装设计的案例
  • 白山北京网站建设中国纪检监察报网评文章
  • seo门户网站建设方案深圳 购物商城网站建设
  • 海南建站中心上海网站建设上海员君
  • 苏州免费模板建站甘肃省seo关键词优化
  • 做网站推广可行吗外贸销售工作内容
  • 网站备案 取名资讯通不过收费下载网站源码
  • 沈阳做网站软件长沙网站开发智
  • 在c盘做网站可以吗wordpress 最新文章展示