当前位置:网站首页>Application of stack -- bracket matching problem
Application of stack -- bracket matching problem
2022-07-01 12:23:00 【Between the steps】
The application of the stack —— Bracket matching problem
#include<stdio.h>
#define MaxSize 10
typedef struct{
char data[MaxSize]; // Static arrays hold the elements in the stack
int top; // Top pointer of stack
}SqStack;
// Initialization stack
void InitStack(SqStack &S){
}
// Judge whether the stack is empty
bool StackEmpty(SqStack s){
}
// Put new elements on the stack
bool Push(SqStack &s,char x){
}
// Stack top element out of stack , use x return
bool Pop(SqStack &s, char &x){
}
bool braketCheak(char str[],int length){
// Put characters in str[] Array ,length It's the length
SqStack S; // Create a stack and allocate space for it
InitStack(S);
for(int i=0;i<length;i++){
if(str[i]=='(' ||str[i]=='['||str[i]=='{'){
Push(S,str[i]); // Left bracket in stack
}else{
if(StackEmpty(S)) // If it's not the left parenthesis , It's time to get out of the stack , If the stack is empty , be false
return false;
char topElem; // Out of stack elements
Pop(S,topElem); // Stack top element out of stack
if(str[i]==')'&& topElem!='(')
return false;
if(str[i]==']'&& topElem!='[')
return false;
if(str[i]=='}'&& topElem!='{')
return false;
}
}
return StackEmpty(S); // If the stack is empty, return true, Otherwise return to false
}
int main(){
}
边栏推荐
- Technology sharing | MySQL: how about copying half a transaction from the database?
- 【MAUI】为 Label、Image 等控件添加点击事件
- 指定的服务已标记为删除
- [speech signal processing] 3 speech signal visualization -- prosody
- 被锡膏坑了一把
- 自组织是管理者和成员的双向奔赴
- CPI tutorial - asynchronous interface creation and use
- Golang introduces the implementation method of the corresponding configuration file according to the parameters
- The Missing Semester
- GID: open vision proposes a comprehensive detection model knowledge distillation | CVPR 2021
猜你喜欢

Sort out relevant contents of ansible

Onenet Internet of things platform - mqtts product equipment connected to the platform

Seckill system 03 - redis cache and distributed lock

【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN

Sleep quality today 79 points

Le semester manquant

Build yocto system offline for i.mx8mmini development board

第十四章 信号(四)- 多进程任务示例

Ipv6-6to4 experiment

Message queue monitoring refund task batch process
随机推荐
[datawhale202206] pytorch recommendation system: precision model deepfm & DIN
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN
AI抠图工具
leetcode 406. Queue Reconstruction by Height(按身高重建队列)
Onenet Internet of things platform - the console sends commands to mqtt product devices
队列的链式存储
栈的应用——括号匹配问题
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
[JS advanced] promise explanation
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
Implementation of address book management system with C language
Uniapp uses uni upgrade Center
Summary of JFrame knowledge points 1
JS reverse | m3u8 data decryption of a spring and autumn network
C summary of knowledge points 3
The Missing Semester
【MAUI】为 Label、Image 等控件添加点击事件
Interpretation of R & D effectiveness measurement framework