![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
#栈--队列--数组
chen_512
这个作者很懒,什么都没留下…
展开
-
括号匹配-
//数组存储class Solution {public: bool isValid(string s) { if (s.empty()) return true; char s1[10001]; int top = -1; for (char c : s) { if (c == '(' || c == '[' || c == '{') { s1[++t原创 2022-04-04 10:46:41 · 240 阅读 · 0 评论 -
逆波兰表达式
//逆波兰表达式class Solution{public: int evalRPN(vector<string>& tokens) { stack<int> mystack;//tokens只包含了int和四个表达式则可以用int if (tokens.empty()) return 0; for (string s : tokens) {原创 2022-04-05 09:54:51 · 270 阅读 · 0 评论 -
链队列--带头节点||不带头结点
//带头结点#include<iostream>typedef int ElemType;using namespace std;struct Node { ElemType data; Node* next;};class Queue {public: Queue(); bool QueueEmpty() const; bool EnQueue(ElemType e); bool DeQueue(ElemType& e); bool GetHead(Elem原创 2022-04-02 11:03:54 · 123 阅读 · 0 评论 -
队列--循环--顺序存储
//顺需存储#include<iostream>using namespace std;#define MaxSize 60typedef int ElemType;typedef struct { ElemType data[MaxSize]; int front, rear;}SqQueue;bool InitSqQueue(SqQueue& Q){ Q.front = Q.rear = 0; return true;}bool QueueEmpty(Sq原创 2022-03-31 11:59:07 · 238 阅读 · 0 评论 -
链栈-无头节点-带头节点
//无头节点#include<stdio.h>#include<stdlib.h>typedef int ElemType;typedef struct Node{ ElemType data; struct Node* next;}*LiStack,stack;bool InitStack(LiStack& S){ S = NULL; return true;}bool Empty(LiStack S)//判断栈是否为空{ return (S原创 2022-03-28 10:04:50 · 531 阅读 · 1 评论 -
栈--顺序栈--共享栈
//顺序栈#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#define MaxSize 10typedef int ElemType;typedef struct { ElemType data[MaxSize]; int top;}SqStack;bool InitStack(SqStack& S){ S.top = -1;//指向当前栈顶元素若=0则指向下一个存储位置 return true;}bool S原创 2022-03-27 11:55:12 · 133 阅读 · 0 评论