数据结构第五周项目-括号的匹配
来源:互联网 发布:jersey 返回对象json 编辑:程序博客网 时间:2024/05/29 15:33
/* *Copyright (c) 2017,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:多文件组织 *作 者:张昕 *完成日期:2017年12月17日 *版 本 号:v1.0 */
假设表达式中允许三种括号:圆括号、方括号和大括号。编写一个算法,判断表达式中的各种左括号是否与右括号匹配。
例如,输入2+(3+4)*2+{[3]}-8,输出匹配正确;输入2+(3+4*[2)+{[3]}-8,输出匹配错误。
头文件sqstack.h见顺序栈算法库
#include <stdio.h>#include "sqstack.h"int main(){ char c; char st[50]; int d=1, i; SqStack *s; InitStack(s); printf("请输入表达式:"); scanf("%s", st); for(i=0; st[i]!='\0'&&d; i++) { switch(st[i]) { case'(': case'[': case'{': Push(s, st[i]); break; case')': Pop(s, c); if(c!='(') d=0; break; case']': Pop(s, c); if(c!='[') d=0; break; case'}': Pop(s,c); if(c!='{') d=0; break; } } if(StackEmpty(s)&&d==1) printf("配对正确!!\n"); else printf("配对错误!!\n"); return 0;}
阅读全文
0 0
- 数据结构第五周项目-括号的匹配
- 数据结构第五周项目3--括号的匹配
- 数据结构 第五周项目三 括号的匹配
- 第五周项目3--括号的匹配
- 第五周 项目3-括号的匹配
- 第五周项目3 -括号的匹配
- 第五周 项目3 - 括号的匹配
- 第五周项目3-括号的匹配
- 第五周项目3-括号的匹配
- 第五周项目3-括号的匹配
- 第五周项目三 括号的匹配
- 第五周【项目三-括号的匹配】
- 第五周 项目3-括号的匹配
- 第五周项目3-括号的匹配
- 第五周--项目3-括号的匹配
- 第五周- 项目三 括号的匹配
- 第五周--项目三--括号的匹配
- 第五周项目三-括号的匹配
- 错误1:malloc.c:2394
- Tensorflow: 保存和复原模型(save and restore)
- vue中npm run dev运行项目不能自动打开浏览器!
- Python数据抓取(2) —简单网络爬虫的撰写
- 支付倒计时
- 数据结构第五周项目-括号的匹配
- Python实现的检测web服务器健康状况的小程序
- WebViewJavascriptBridge是一个Objective-C与JavaScript进行消息互通的三方库
- 【TensorFlow】数据处理(对图像的处理)
- 链式调用-普通调用
- React Native 学习资源精选仓库(汇聚知识,分享精华)
- SimpleDateFormat的使用
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- android六大布局和UI组件