c++ 栈
碳酸钙的01妖精
这个作者很懒,什么都没留下…
展开
-
链栈的数据结构实现
typedef struct node{ int data; struct node * next;}LinkStackNode, *LinkStack;//top相当于是头指针,本质上是头插法int Push(LinkStack top, int x) //相当于链表的插入操作{ LinkStack temp; temp=(LinkStack)malloc(sizeof(LinkStackNode)); if(temp==NULL) return -1.原创 2020-09-20 15:58:11 · 158 阅读 · 0 评论 -
输出命题公式的真值表(后缀表达式)
1422.输出命题公式的真值表时限:1000ms 内存限制:10000K 总时限:3000ms描述先输入一个正整数n(n小于等于10),表示共有n个命题变元,再输入一个类似于逆波兰表达式的字符串表示一个命题公式,约定在该字符串中用一位的十进制数表示一个命题变元,用a、o、n、i、e分别表示且、或、非、蕴含、等值,用类似于逆波兰表达式形式的字符串表示的命题公式的真值表波兰表达式(即二元...原创 2018-11-16 13:51:02 · 4636 阅读 · 0 评论 -
栈的stl
stack<int> s; 创建一个空的堆栈对象 s stack<int, list<int> > s1; stack<int, list<int> > s2(s1); 利用 s1 ,创建一个以双向链表为底层容器的空堆栈对象 s2 。c++ stl栈stack的头文件为: #i...原创 2018-08-20 23:18:16 · 292 阅读 · 0 评论 -
洛谷 P1143 进制转换
洛谷P1143 进制转换本题题解为转载题目描述请你编一程序实现两种不同进制之间的数据转换。输入输出格式输入格式:输入数据共有三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进制数,若n>10则用大写字母A~F表示数码10~15,并且该n进制数对应的十进制的值不超过1000000000,第三行也是一个正整数,表示转换之后的数的进制m(2≤m≤16)。输出格式:...原创 2018-03-13 21:45:49 · 697 阅读 · 0 评论 -
顺序栈的数据结构的实现
顺序栈typedef struct{ int elem[MAXN]; int top;}SeqStack;void InitStack(SeqStack *S){ S->top=-1;}void Push(SeqStack *S ,int x) //栈的首元素下标是0{ if(S->top==MAXN-1) //栈已满 retu...原创 2018-06-25 17:07:58 · 221 阅读 · 0 评论 -
逆波兰式(数组建栈+中缀表达式转后缀表达式+中缀表达式转前缀表达式)
逆波兰式(字符栈)#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ int i; char str[2000]; char seqstack[2000]; seqstack[0]='#';//用这个做首元素可做pop终止的操作。 int top=0...原创 2018-06-20 11:59:53 · 429 阅读 · 0 评论 -
表达式括号匹配(字符数组栈)
表达式括号匹配(字符数组栈)#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char str[2000]; char seqstack[2000];//字符数组构成的栈比整型数组构成的栈形象多了,因为'\0'本身就完全符合pop scanf("%s",str...原创 2018-06-20 12:04:20 · 494 阅读 · 0 评论 -
ZOJ-1004 Anagrams by Stack(栈+深搜)
ZOJ-1004 Anagrams by Stack(栈+深搜) How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TROT to TORT: [ i i i i o o o o i o i i o...原创 2018-03-20 22:12:54 · 196 阅读 · 0 评论 -
HDU-1022 Train Problem I(栈)
HDU-1022 Train Problem I(栈)Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the I...原创 2018-03-20 12:59:13 · 129 阅读 · 0 评论 -
P1449 后缀表达式计算(数组建栈+后缀表达式计算+前缀表达式计算)
P1449 后缀表达式计算题目描述所谓后缀表达式是指这样的一个表达式:式中不再引用括号,运算符号放在两个运算对象之后,所有计算按运算符号出现的顺序,严格地由左而右新进行(不用考虑运算符的优先级)。如:3*(5–2)+7对应的后缀表达式为:3.5.2.-*7.+@。’@’为表达式的结束符号。‘.’为操作数的结束符号。输入输出格式输入格式:输入:后缀表达式输出格式:输出:表达式的值输入输出样例输入样例...原创 2018-03-23 15:44:11 · 365 阅读 · 0 评论