当前位置:网站首页>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(){
}
边栏推荐
- Use of easyexcel
- The operation process of using sugar to make a large data visualization screen
- 2022-06-28-06-29
- C summary of knowledge points 3
- leetcode 406. Queue Reconstruction by Height(按身高重建队列)
- STM32 project practice (1) introduction and use of photosensitive resistor
- Onenet Internet of things platform - create mqtts products and devices
- ANSI/UL 94 VTM薄质材料垂直燃烧测试
- Joint Time-Frequency and Time Domain Learning for Speech Enhancement
- MySQL data table creation
猜你喜欢

Machine learning - Data Science Library Day 3 - Notes

The Missing Semester

BIM and safety in road maintenance-buildSmart Spain

Consolidate -c operator

2022-06-28-06-29

【20220605】文献翻译——虚拟现实中的可视化:一个系统的回顾

Indefinite integral

Dlhsoft Kanban, Kanban component of WPF

2022-06-28-06-29

Interpretation of R & D effectiveness measurement framework
随机推荐
Golang des-cbc
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7
Switch basic experiment
Computer graduation project asp Net hotel room management system VS development SQLSERVER database web structure c programming computer web page source code project
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6
91. (cesium chapter) cesium rocket launch simulation
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4
Onenet Internet of things platform - mqtt product devices send messages to message queues MQ
MySQL common functions
Ansible Playbook
使用BurpSuite对app抓包教程
Joint Time-Frequency and Time Domain Learning for Speech Enhancement
Good luck brought by years of persistence
CPI tutorial - asynchronous interface creation and use
Onenet Internet of things platform - mqtt product equipment upload data points
One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
指定的服务已标记为删除
Chapter 14 signals (IV) - examples of multi process tasks
ASTM D 3801 vertical burning test of solid plastics
Ansible的playbook