symbols匹配问题

#include<iostream>
#include<string>
using namespace std; struct Node
{
char data;
Node*next;
}; struct LinkStack
{
Node*top;
}; LinkStack*create()
{
LinkStack*stack = new LinkStack;
stack->top = NULL;
return stack;
} bool isEmpty(LinkStack*stack)
{
return (stack->top == NULL);
} void pop(LinkStack*stack)
{
Node*p = stack->top;
stack->top = stack->top->next;
delete p;
} void push(LinkStack*stack, char item)
{
Node*p = new Node;
p->data = item;
p->next = stack->top;
stack->top = p;
} char Top(LinkStack*stack)
{
return stack->top->data;
} int main()
{
int n;
cin >> n;
while (n-->0)
{
string s;
cin >> s;
LinkStack*stack = create();
bool flag = true;
int n = s.size(); for (int i = 0; i < n; i++)
{
if (s[i] == '(' || s[i] == '[' || s[i] == '{')
push(stack, s[i]);
if (s[i] == ')')
{
if (!isEmpty(stack))
{
if (isEmpty(stack) && Top(stack) != '(')
{
flag = false;
break;
}
else
{
pop(stack);
}
}
else
{
flag = false;
break;
}
}
else if (s[i] == ']')
{
if (!isEmpty(stack))
{
if (Top(stack) != '[')
{
flag = false;
break;
}
else
{
pop(stack);
}
}
else
{
flag = false;
break;
}
}
else if (s[i] == '}')
{
if (!isEmpty(stack))
{
if (Top(stack) != '{')
{
flag = false;
break;
}
else
{
pop(stack);
}
}
else
{
flag = false;
break;
}
}
}
if (!isEmpty(stack))
flag = false;
if (flag)
cout << "Yes" << endl;
if (!flag)
cout << "No" << endl; delete stack;
}
return 0;
}

  

Balancing Symbols的更多相关文章

  1. Undefined symbols for architecture arm64解决方案

    在iOS开发中经常遇到的一个错误是Undefined symbols for architecture arm64,这个错误表示工程某些地方不支持arm64指令集.那我们应该怎么解决这个问题了?我们不 ...

  2. Clang: Undefined symbols, but it is there using nm.

    https://stackoverflow.com/questions/36662920/xcode-clang-link-build-dynamic-framework-or-dylib-not-e ...

  3. 转载:《TypeScript 中文入门教程》 16、Symbols

    版权 文章转载自:https://github.com/zhongsp 建议您直接跳转到上面的网址查看最新版本. 介绍 至ECMAScript 2015开始,symbol成为了一种新的原始类型,就像n ...

  4. ios build时,Undefined symbols for architecture xxx问题的总结

    简单来说,Undefined symbols基本上等于JAVA的ClassNotFoundException,最常见的原因有这几种: build的时候没有加framework 比如说,有一段代码我用了 ...

  5. Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_The49DayPersonalFullscreenGiftModel", referenced from: objc-class-ref in The49DayPersonalRoomGiftModel.o ld: symbol(s) not found for a

    Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_The49DayPersonalFullscreenGiftModel&q ...

  6. ios开发错误之: Undefined symbols for architecture x86_64

    错误如下: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_RoutingHTTPServer", refere ...

  7. could not read symbols: File format not recognized

    arm-linux-gnueabi-readelf工具解决问题 编译一个32位平台的内核时,出现如下错误提示: libschw.a: could not read symbols: File form ...

  8. 解决duplicate symbols for architecture x86_64错误

    duplicate symbols for architecture x86_64 两个不第三方SDK之间的文件里面内容重复了,类似 file.h+file.m 和 CHfile.h+CHfile.m ...

  9. How to pronounce symbols on keyboard

    Refefrence: http://answers.yahoo.com/question/index?qid=20100607151104AAtQxhc ~ “tilde” or “tweedle” ...

随机推荐

  1. C++笔记(to be cont'd)

    最近在看这个:LearnCpp 主要是一些我自己容易忽视的地方 记一些笔记在下面,还有错漏地方请不吝赐教 CH1.10 Preprocessing The preprocessor copies th ...

  2. Xcode8注释有时会失效的解决方法

    1.苹果开发解决了xcode ghost,而且Xcode8也取消了三方插件的功能,所以注释有时会失效,解决办法终端运行命令:sudo /usr/libexec/xpccachectl  回车 +  输 ...

  3. github的使用与问题

    GIT密钥的生成步骤 一 .设置Git的user name和email: $ git config --global user.name "name" $ git config - ...

  4. android使用shape做selector按钮按下和弹起的动画

    平时效果:   按下效果: selector代码: <?xml version="1.0" encoding="utf-8"?> <selec ...

  5. Partial Tree

    Partial Tree 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5534 完全背包 做这题前去学习了下完全背包,觉得这个优化简直神技!(以前都是 ...

  6. Beef

    修改配置文件/usr/share/beef-xss/config.yaml (1)改vi beef侦听端口:    http:   port:3000(改为80) (2)与Metaspolit关联: ...

  7. js--冒泡排序[由小到大]

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  8. [jquery备忘]

    has :包含,找元素里面的子元素(单个) <div><span>123</span></div> $('div').has('span').css() ...

  9. Tomcat 配置支持APR

    对ARP支持,需要安装以下库: APR library JNI wrappers for APR used by Tomcat (libtcnative) OpenSSL libraries 其中JN ...

  10. navicat导出表结构-->导入powerdesigner

    01 转储sql文件-->导出表结构和数据 02数据传输--高级--插入记录(去掉)-->只导出表结构 目标-->001连接---->把数据导入指定ip的数据表中 目标--&g ...