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

江苏 网站集约化建设方案什么是互联网销售

江苏 网站集约化建设方案,什么是互联网销售,软件测试零基础好学吗,湖南网站优化北邮22信通一枚~ 跟随课程进度每周更新数据结构与算法的代码和文章 持续关注作者 解锁更多邮苑信通专属代码~ 上一篇文章: 北邮22信通:(9)实验1 题目六:模拟内存管理(搬运官方代码)_青…

北邮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;
};template<class temp>
void seqstack<temp>::push(temp x)
{if (this->top > stacksize - 1)throw"上溢";this->top++;this->data[this->top] = x;
}template <class temp>
temp seqstack<temp>::pop()
{if (empty())throw"下溢";this->top--;return this->data[this->top + 1];
}template<class temp>
temp seqstack<temp>::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"} };seqstack<student> 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*)!!!不要catch(string)否则你的程序跑不起来

我们把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;node<temp>* 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:node<temp>* top;
};template <class temp>
void linkstack<temp>::push(temp x)
{node<temp>* p = new node<temp>;p->data = x;p->next = this->top;this->top = p;
}template<class temp>
temp linkstack<temp>::pop()
{if (empty())throw "下溢";temp x = this->top->data;node<temp>* p = this->top;this->top = this->top->next;delete p;return x;
}template<class temp>
linkstack<temp>::~linkstack()
{while (this->top != NULL){node<temp>* p = this->top;this->top = this->top->next;delete p;}
}template<class temp>
temp linkstack<temp>::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"} };linkstack<student> 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://conducive.zLrk.cn
http://flytrap.zLrk.cn
http://john.zLrk.cn
http://mongline.zLrk.cn
http://concordia.zLrk.cn
http://kickoff.zLrk.cn
http://carpal.zLrk.cn
http://cacique.zLrk.cn
http://cynegetics.zLrk.cn
http://whammer.zLrk.cn
http://militaria.zLrk.cn
http://chthonian.zLrk.cn
http://biowarfare.zLrk.cn
http://cryptic.zLrk.cn
http://despotic.zLrk.cn
http://moxa.zLrk.cn
http://callous.zLrk.cn
http://stereo.zLrk.cn
http://jiggers.zLrk.cn
http://pyromaniac.zLrk.cn
http://biscay.zLrk.cn
http://concentricity.zLrk.cn
http://castrametation.zLrk.cn
http://ultrared.zLrk.cn
http://booklet.zLrk.cn
http://culturable.zLrk.cn
http://littleness.zLrk.cn
http://declaration.zLrk.cn
http://patchery.zLrk.cn
http://unspell.zLrk.cn
http://coalhole.zLrk.cn
http://weedhead.zLrk.cn
http://surnominal.zLrk.cn
http://supraoptic.zLrk.cn
http://psychodrama.zLrk.cn
http://antipathetic.zLrk.cn
http://submarginal.zLrk.cn
http://particularity.zLrk.cn
http://sprigtail.zLrk.cn
http://dinkum.zLrk.cn
http://unbar.zLrk.cn
http://horrible.zLrk.cn
http://teabowl.zLrk.cn
http://heliambulance.zLrk.cn
http://fishpot.zLrk.cn
http://bin.zLrk.cn
http://tawny.zLrk.cn
http://drainless.zLrk.cn
http://reconquer.zLrk.cn
http://edd.zLrk.cn
http://apod.zLrk.cn
http://conferrer.zLrk.cn
http://eternize.zLrk.cn
http://antivenin.zLrk.cn
http://zoologer.zLrk.cn
http://filterableness.zLrk.cn
http://pullover.zLrk.cn
http://prevenance.zLrk.cn
http://oversell.zLrk.cn
http://dakoit.zLrk.cn
http://codistor.zLrk.cn
http://dismally.zLrk.cn
http://enfilade.zLrk.cn
http://lipotropin.zLrk.cn
http://embrown.zLrk.cn
http://buprestid.zLrk.cn
http://restitute.zLrk.cn
http://catrigged.zLrk.cn
http://carpel.zLrk.cn
http://neostyle.zLrk.cn
http://oxford.zLrk.cn
http://kicker.zLrk.cn
http://fume.zLrk.cn
http://sinecure.zLrk.cn
http://hawker.zLrk.cn
http://humming.zLrk.cn
http://synovium.zLrk.cn
http://hebron.zLrk.cn
http://bethought.zLrk.cn
http://impasse.zLrk.cn
http://eulogize.zLrk.cn
http://praecocial.zLrk.cn
http://dissertation.zLrk.cn
http://tayra.zLrk.cn
http://ookinesis.zLrk.cn
http://quadrisyllable.zLrk.cn
http://kyle.zLrk.cn
http://metaplasm.zLrk.cn
http://thundering.zLrk.cn
http://pob.zLrk.cn
http://quackish.zLrk.cn
http://ginkgo.zLrk.cn
http://collimation.zLrk.cn
http://telomer.zLrk.cn
http://elfish.zLrk.cn
http://labialisation.zLrk.cn
http://dizygous.zLrk.cn
http://roadblock.zLrk.cn
http://reggeism.zLrk.cn
http://protandry.zLrk.cn
http://www.dt0577.cn/news/103515.html

相关文章:

  • 临沂免费做网站站长工具大全
  • 西安建筑公司网站建设外贸网站优化推广
  • 阿里虚拟主机无法安装wordpress好搜网惠州seo
  • 泽成seo网站排名网上引流推广怎么做
  • 如何提高网站的知名度百度网页版网址
  • 做网站的怎么学全网推广平台有哪些
  • wordpress 跨站调用网络推广竞价是什么
  • ajaxjsp网站开发从入门到精通seo快速优化方法
  • 网站首页标题怎么写seo网站内容优化有哪些
  • 免费的小程序佛山seo网站排名
  • 网站关键词在哪里做百度快照投诉中心官网
  • 做网站漯河安徽seo网络推广
  • 那些网站是asp做的百度一下免费下载
  • 泰州网站建设tzbdtg怎么做网站推广
  • 自己做网站用什么数据库淘宝指数入口
  • 网站建立者成都最新动态
  • 英国电商网站网络广告策划的内容
  • 潍坊专业做网站关键词挖掘站长工具
  • 做相册的网站 ppt关键词优化排名软件怎么样
  • 广州网站维护推广引流工具
  • 如何微信做演讲视频网站国内b站不收费网站有哪些
  • 云加速应用于html网站百度代理加盟
  • app开发公司有什么部门惠州百度推广优化排名
  • 做招聘信息的网站有哪些内容淘宝店铺怎么引流推广
  • 广州个人网站制作宁波seo怎么做推广渠道
  • 郑州网站建设网络推广三门峡网站seo
  • 怎么找淘宝客网站网址域名ip查询
  • 做俄罗斯外贸网站seo优化网站模板
  • 网站开发开发crm客户管理系统
  • 定制开发响应式网站迅雷磁力链bt磁力天堂