当前位置:网站首页>bracket matching
bracket matching
2022-08-04 20:55:00 【[email protected]】
[Example] The parentheses in arithmetic expressions in C language are only parentheses.Write an algorithm to determine whether the parentheses in an expression are paired correctly. The expression has been stored in the character array exp[], and the number of characters in the expression is n.
int match(char exp[],int n){char stack[maxSize]; //maxSize is a defined constantint top=-1;int i;for(i=0;i<n;++i){if(exp[i]==')')if(top==-1)return 0;else--top;else if(exp[i]=='(')stack[++top]='(';}if(top==-1)return 1;elsereturn 0;}版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/216/202208042042152123.html
边栏推荐
猜你喜欢
随机推荐
WIN10系统如何开启终端
QT(41)-多线程-QTThread-同步QSemaphore-互斥QMutex
【2022牛客多校5 A题 Don‘t Starve】DP
Matlab画图2
【C语言】指针和数组的深入理解(第三期)
[Academic related] Tsinghua professor persuaded to quit his Ph.D.:I have seen too many doctoral students have mental breakdowns, mental imbalances, physical collapses, and nothing!...
【CAS:2306109-91-9 |胺-PEG4-脱硫生物素】价格
项目难管理?先学会用好甘特图(内附操作方法及实用模板)
【AGC】构建服务1-云函数示例
Tear down the underlying mechanism of the five JOINs of SparkSQL
该如何训练好深度学习模型?
链路聚合技术及VRRP
【一起学Rust | 进阶篇 | Service Manager库】Rust专用跨平台服务管理库
在vs code中进行本地调试和开启本地服务器
uwp ScrollViewer content out of panel when set the long width
Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
三种方式设置特定设备UWP XAML view
C语言基础[通俗易懂]
Desthiobiotin-PEG4-Azide_脱硫生物素-叠氮化物 100mg
idea源码无法下载









