博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa 673 Parentheses Balance (stack)
阅读量:7219 次
发布时间:2019-06-29

本文共 636 字,大约阅读时间需要 2 分钟。

题目描述 : 判断字符串是不是符合正确的表达式形式。

要点 : 考虑字符串为空的时候,用getline输入,每一次判断后如果为No则要清空栈。对称思想。

             注意输入格式。

代码:

#include 
#include
#include
#include
#include
#include
using namespace std;int main(){ stack
s; int n; int value[200]; cin>>n; cin.ignore(); string str; while(n--) { getline(cin , str); int len = str.size(); if(len == 0) cout<<"Yes\n"; else { for(int i=0; i
0) s.pop(); else s.push(value[i]); } } if(s.empty()) cout<<"Yes\n"; else { cout<<"No\n"; while(!s.empty()) { s.pop(); } } } } return 0;}

 

转载于:https://www.cnblogs.com/wxisme/p/4363758.html

你可能感兴趣的文章
MUI 里js动态添加数字输入框后,增加、减少按钮无效
查看>>
python pip 更换国内安装源(windows)
查看>>
结对编程2后篇
查看>>
oracle exp 和 imp 数据和表结构互相独立导出导入
查看>>
iphone-common-codes-ccteam源代码 CCNSPredicate.m
查看>>
这次项目中应该注意的问题和应该保持的好习惯
查看>>
python-数据结构化与保存
查看>>
LeetCode - 551. Student Attendance Record I
查看>>
Java用户线程和守护线程
查看>>
ClassLoader类加载机制&&JVM内存管理
查看>>
Caml语句 查询分配给当前用户及当前组
查看>>
记一次源码分析
查看>>
php版本引起的const问题
查看>>
js实现60s倒计时效果
查看>>
【POJ 2176】Folding
查看>>
redis的过期策略以及内存淘汰机制
查看>>
阿牛的EOF牛肉串
查看>>
随笔2013/2/13
查看>>
笨办法32循环和列表
查看>>
java序列化
查看>>