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

哪个网站做h5比较好涂料做哪个网站好

哪个网站做h5比较好,涂料做哪个网站好,如何在vps上搭建网站,wordpress标题大小三十五、栈 示例&#xff1a; #include <iostream> using namespace std; typedef int ElemType; // 自定义链栈的数据元素为整数。 struct SNode // 链栈的结点。 { ElemType data; // 存放结点的数据元素。 struct SNode* next; // 指向下一个结点的指针。 }; // 初始化…

三十五、栈
示例:
#include <iostream>
using namespace std;
typedef int ElemType; // 自定义链栈的数据元素为整数。
struct SNode // 链栈的结点。
{
ElemType data; // 存放结点的数据元素。
struct SNode* next; // 指向下一个结点的指针。
};
// 初始化链栈,返回值:失败返回 nullptr,成功返回头结点的地址。
SNode* InitStack()
{
SNode* head = new (std::nothrow) SNode; // 分配头结点。
if (head == nullptr) return nullptr; // 内存不足,返回失败。
head->next = nullptr; // 头结点的下一结点暂时不存在,置空。
return head; // 返回头结点。
}
// 销毁链栈。
void DestroyStack(SNode* head)
{
// 销毁链栈是指释放链栈全部的结点,包括头结点。
SNode* tmp;
while (head != nullptr)
{
tmp = head->next; // tmp 保存下一结点的地址。
delete head; // 释放当前结点。
head = tmp; // 指针移动到下一结点。
}
}
// 元素入栈,返回值:false-失败;true-成功。
bool Push(SNode* head, const ElemType& ee)
{
if (head == nullptr) { cout << "链栈不存在。\n"; return false; }
SNode* tmp = new (std::nothrow) SNode; // 分配一个新结点。
if (tmp == nullptr) return false;
tmp->data = ee; // 把元素的值存入新结点。
// 处理 next 指针。
tmp->next = head->next;
head->next = tmp;
return true;
}
// 显示链栈中全部的元素。
void PrintStack(const SNode* head)
{
if (head == nullptr) { cout << "链栈不存在。\n"; return; }
SNode* pp = head->next; // 从第 1 个结点开始。
while (pp != nullptr)
{
cout << pp->data << " "; // 如果元素为结构体,这行代码要修改。
pp = pp->next; // 指针往后移动一个结点。
}
cout << endl;
}
// 求链栈的长度,返回值:>=0-栈 SS 结点的个数。
size_t StackLength(SNode* head)
{
if (head == nullptr) { cout << "链栈不存在。\n"; return 0; }
SNode* pp = head->next; // 头结点不算,从第 1 个结点开始。
size_t length = 0;
while (pp != nullptr) { pp = pp->next; length++; }
return length;
}
// 元素出栈。
bool Pop(SNode* head,ElemType &ee)
{
if (head == nullptr) { cout << "链栈不存在。\n"; return false; }
if (head->next == nullptr) { cout << "链栈为空,没有结点。\n"; return false; }
SNode* pp = head->next; // pp 指向第一个节点。
head->next = head->next->next; // 修改头结点的 next 指针。
ee = pp->data;
delete pp; // 删除第一个节点。
return true;
}
int main()
{
SNode* SS = InitStack(); // 初始化链栈 SS。
cout << "入栈三个元素(1、2、3)。\n";
Push(SS, 1);
Push(SS, 2);
Push(SS, 3);
PrintStack(SS); // 把链栈中全部的元素显示出来。
cout << "链栈的长度:" << StackLength(SS) << endl;
// 元素出栈。
ElemType ee;
Pop(SS,ee);
cout << "出栈的元素的值是:" << ee << endl;
DestroyStack(SS); // 销毁链栈 SS。
}
 

http://www.yayakq.cn/news/789535/

相关文章:

  • 深一互联网站建设怎样基于html的网站设计
  • 网页制作网站首页设计wordpress打开html
  • 系统优化的影响因素seo赚钱
  • 做视频上传多少个网站百度网页推广费用
  • 完全菜鸟七天学会建网站wordpress 加载排版
  • 漂亮网站欣赏格拉苏蒂手表网站
  • 做竞价网站服务器多少钱ip域名查询地址
  • 网站开发人员主要干什么的安装完成wordpress后如何使用
  • 济宁房产网站建设银川网站建设哪家好叫啥名字
  • 企业网站用什么套站百度商城官网首页
  • 制作天下网站wordpress备份文件
  • 购物网站开发一般使用什么语言docker运行wordpress
  • 快速优化网站建设中国电子网
  • 潍坊住房和城乡建设局招标网站网站备案换接入商
  • 做网页设计卖钱的网站深圳建设网站推荐
  • 网站 申请建设教育工程网站
  • 流行用什么做网站玩游戏的网页
  • 优化企业门户网站网页浏览器软件有哪些
  • 专门做衬衣网站wordpress php调优
  • 房地产建设企业网站国外app推广平台有哪些
  • 网站建设深圳给原码获取网页 代码 做网站
  • 河南营销型网站江苏优质网站制作公司
  • 怎么开通个人网站请人做网站设计的方案
  • 丰台企业网站建设wordpress登陆访问
  • 五指山网站开发价格保定手机网站制作
  • 企业网站计划书wordpress做双语网站
  • 济南市网站建设做网站珊瑚橙颜色怎么搭配好看
  • 网站的二维码怎么做网站建设咨询云尚网络
  • 个人网站的名称j2ee网站开发参考文献
  • 彩票网站搭建 做网站天津微信网站建设