• 2024-07-21数据结构:栈的基本概念、顺序栈、共享栈以及链栈
    相关概念栈(Stack)是只允许在一端进行插入或删除操作的线性表。栈顶(Top):线性表允许插入删除的那一端。栈底(Bottom):固定的,不允许进行插入和删除的另一端。栈的基本操作InitStack(&S):初始化一个空栈S。StackEmpty(S):判断一个栈是否为空,若栈S为空则返回true,否则返回false。
  • 2024-07-21数据结构——栈
    一、栈的定义我们都知道线性表是具有相同数据类型的n(n为表长且n>=0)个数据元素的有限序列。而栈,是只允许在一端进行插入或删除操作的线性表。就如汉罗塔相似,你只能从头顶放入或拿走方块。  重要术语:栈顶、栈底、空栈我们从图就很容易理解这三个术语:空栈:指线性表内
  • 2024-07-11线性表——顺序栈
    #include<bits/stdc++.h>usingnamespacestd;#defineMaxSize2typedefstruct{ intdata[MaxSize]; inttop;}SqStack;//初始化voidInitStack(SqStack&S){ S.top=-1;}//判断栈空和已入栈元素个数voidStackEmpty(SqStackS){ if(S.top==-1) cout<<&
  • 2024-07-105-顺序栈的操作
    #include<stdio.h>#include<stdlib.h>#include<stdbool.h>typedefintElemType;/**/#defineMaxSize50/**/typedefstruct{ElemTypedata[MaxSize];/*top:数组索引从0开始=MaxSize-1*/inttop;}SqStack;/*初始化栈*/voidInit
  • 2024-07-08洛谷p1449后缀表达式题解
    #include<stdio.h>#include<stdlib.h>#defineMAXSIZE100typedeflongElemType;typedefstruct{ ElemType*base; ElemType*top; intStackSize;}sqStack;voidInitStack(sqStack*s){ s->base=(ElemType*)malloc (MAXSIZE*sizeof(ElemTyp
  • 2024-06-21c/c++ 数据结构 顺序栈
    本文是以c语言的风格编写的c++程序。栈的特点:先进后出,后进先出。顺序栈的结构定义:一个数组以及一个”指针“(不是真正的指针,而是位置变化的说明)#include<stdio.h>#include<malloc.h>#defineMaxsize20typedefstruct{ intdata[Maxsize]; inttop;}SqStack; 初
  • 2024-06-128587 行编辑程序
    Description 利用栈编写简单的行编辑程序:接受用户从终端输入的程序或数据,在输入过程中,允许用户输入出差错,并在发现有误时可以及时更正。例如:当用户发现刚刚键入的一个字符是错的时,可以补进一个退格符“#”,以表示前一个字符无效;如果发现当前键入的行内差错较多或难以补救,则可
  • 2024-05-23栈和队列1 顺序栈及基本操作实例(进制转换)
    #include<stdio.h>#include<stdlib.h>#defineINITSIZE100#defineINCREAMENT10 typedefstructSqStack{   int*data;   int*top;   intstacksize;}SqStack;voidInitStack(SqStack*L){   L->data=(int*)malloc(INITSIZE*siz
  • 2024-04-18栈1: 栈的顺序存储
    栈:顺序存储栈是一种先进后出(FirstInLastOut,FILO)的数据结构如果你将两个元素压入栈,先加入的元素将在后加入的元素之后出栈栈顶元素值为null(未满时)定义栈的数据结构#defineMAX_SIZE1024//利用数组模拟栈的顺序存储typedefstructsqStack{void*data[MA
  • 2024-04-07顺序栈功能函数(包括判断回文、数值转化、括号匹配)
    一,具体代码#include<iostream>#include<stdlib.h>usingnamespacestd;#defineOK1#defineERROR0#defineMAXSIZE100typedefintElemType;typedefintStatus;typedefstruct {   ElemType*elem;   inttop;}Sqstack;StatusInitStack(Sqstack
  • 2024-04-04让你一次了解透彻栈
    栈的定义栈(stack)是只允许在一端进行插入或删除操作的线性表,区别于前面顺序表和链表不能从中间位置进行操作,具有严格的“专一性”,认准哪一端则只能在该端进行操作。可以理解为栈是限定仅在表尾进行插入和删除操作的线性表。栈的特点:先进后出、后进先出栈的示意图: 关
  • 2024-03-18SWUST OJ 961: 进制转换问题
    题目描述建立顺序栈或链栈,编写程序实现十进制数到二进制数的转换。输入输入只有一行,就是十进制整数。输出转换后的二进制数。样例输入10样例输出1010参考程序#include<iostream>usingnamespacestd;#definemaxsize100voidconcersion(intn){ inta[maxsize
  • 2024-01-21数据结构——栈及相关操作
    #include<bits/stdc++.h>#defineMaxSize10#defineElementTypeinttypedefstruct{ElementTypedata[MaxSize];inttop;}SqStack;voidInitStack(SqStack&S){S.top=-1;}boolStackEmpty(SqStack&S){if(S.top==-1)
  • 2023-11-28纯菜鸟求帮忙看看这代码为什么只能输入两行
    停车场管理[问题描述]设停车场内只有一个的停放n辆汽车的狭长通道,且只有一个大门可供汽车进出。汽车在停车场内按车辆到达时间的先后顺序,依次由北向南排列(大门在最南端,最先到达的第一辆车停放在车场的最北端),若车场内已停满n辆汽车,则后来的汽车只能在门外的便道上等候,一旦
  • 2023-09-269.25
    用栈实现回文字符串123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  • 2023-09-25九月二十五日
    用栈实现回文字符串#include<iostream>#include<string>usingnamespacestd;typedefstruct{chardata[101];inttop;}SqStack;voidInitStack(SqStack&S){S.top=-1;}voidPush(SqStack&S,chare){S.data[++S.top]=e;}vo
  • 2023-09-23力扣练习题
    1#include<bits/stdc++.h>2#defineMAXSIZE1003usingnamespacestd;4typedefstruct{5char*base;6char*top;7intstactsize;8}sqstack;9voidinitstack(sqstack&s){10s.base=newchar[MAXSIZE];11if(!s.ba
  • 2023-09-22九月二十二日
    将数据结构学了一下回文数用栈和双向链表的方式都实现了一下#include<iostream>usingnamespacestd;typedefstruct{chardata[101];inttop;}SqStack;voidInitStack(SqStack&S){S.top=-1;}voidPush(SqStack&S,chare){S.data[++S.top]=e
  • 2023-09-219.21日数据结构练习题
    用栈操作去判断一个字符串是不是回文数列1#include<iostream>2#defineMAXSIZE1003usingnamespacestd;4//定义一个栈的结构体5//包含顶指针,尾指针,长度6typedefstruct{7char*base;8char*top;9intstacksize;10}SqStack;11//创
  • 2023-08-27二叉树的链式存储结构 C++代码实现
    /*二叉树的链式存储结构*/#include<iostream>usingnamespacestd;/*二叉链表的定义*/typedefstructBiTNode{chardata;structBiTNode*lchild,*rchild;}BiTNode;typedefBiTNode*BiTree;//*************************************************
  • 2023-08-27顺序栈的定义、初始化、出栈、入栈等操作 C++代码实现
     #include<iostream>usingnamespacestd;/*顺序栈的定义*/#defineStack_Size100typedefstructsqStack{char*elem;inttop;intstackSize;//栈数组长度}sqStack;/*顺序栈的初始化*/voidinitStack_Sq(sqStack&S){S.elem=ne
  • 2023-07-23数据结构练习笔记——顺序栈的基本操作
    顺序栈的基本操作【问题描述】按照要求完成顺序栈的设计【输入形式】无【输出形式】2019181716151413121110987654321#include<iostream>usingnamespacestd;#include<stdlib.h>#include<stdio.h>#defineSTACKSIZE10#defineINCRE2
  • 2023-06-1216.栈
    1.栈的概念栈(Stack)是一种数据结构,它遵循后进先出(Last-In-First-Out,LIFO)的原则,也就是说,最后进入栈的元素最先被取出。栈是一种线性数据结构,它由多个元素组成,每个元素被称为栈项(stackitem),栈顶(top)是指最后一个被压入栈的元素,栈底(bottom)是指第一个被压入栈的元素。栈的基本操作包括
  • 2023-04-30栈的顺序存储 C语言
    #include<iostream>#include<stdio.h>#defineMAXSIZE50typedefstruct{intdata[MAXSIZE];inttop;}SqStack;//初始化栈voidInitStack(SqStack&s){s.top=-1;}//判断栈空boolStackEmpty(SqStack&s){if(s.top==-1)
  • 2023-04-20
    线性表:顺序表:数组链表:链表顺序栈://sqstack.h#ifndef_SQ_STACK_H_#define_SQ_STACK_H_typedefintdata_t;typedefstruct{data_t*data;intlen;inttop;}sqstack;sqstack*sqstack_create(intlength);intsqstack_destroy(sqstack*s);