文章
94
粉丝
0
获赞
19
访问
2.8k
栈匹配
#include<stdio.h>
#include<stack>
#include<string.h>
using namespace std;
int main()
{
char s[100];
scanf("%s",s);
int l=strlen(s);
// printf("%s\n",s);
stack<char> hash;
if(s[0]=='['||s[0]=='(')
{
hash.push(s[0]);
}
else{
printf("NO\n");
return 0;
}
// printf("%c",hash.top());
for(int i=1;i<l;i++){
if(s[i]=='[' or s[i]=='(')
{
hash.push(s[i]);
&nb...
登录后发布评论
暂无评论,来抢沙发