随笔分类 -  简单栈

一种数据类型的简单应用
摘要:描述现在,有一行括号序列,请你检查这行括号是否配对。输入第一行输入一个数N(0#include #define M 10001char s[M], s1[M];//s是目标数组,s1是栈int main(){ int n, len, top, i; scanf("%d", &n); while(n--){ top = 3;//栈顶 scanf("%s", s+1); len = strlen(s+1); for(i = 1; i <= len; i++){ ... 阅读全文
posted @ 2013-08-18 10:05 心中的阿哲 阅读(144) 评论(0) 推荐(0)
摘要:总是wa~#include int main(){ int n, i, j, k, atop, cmd[20]; char a[10], b[10]; while(scanf("%d %s %s", &n, a, b) != EOF){ for(i = 0, j = 0, k = 0; i 0 && a[atop - 1] == b[j]){ cmd[k++] = 0; j++; ... 阅读全文
posted @ 2013-08-12 12:37 心中的阿哲 阅读(172) 评论(0) 推荐(0)
摘要:DescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a d 阅读全文
posted @ 2013-08-09 23:09 心中的阿哲 阅读(217) 评论(0) 推荐(0)
摘要:描述Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20,add(10,98)的值是108等等。经过训练,Dr.Kong设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式。假设表达式可以简单定义为:1.一个正的十进制数x是一个表达式。2.如果x和y是表达式,则函数min(x,y)也是表达式,其值为x,y中的最小数。3.如果x和y是表达式,则函数max(x,y)也是表达式,其值为x,y中的最大数。4.如果x和y是表达式,则函数add(x,y)也是表达式,其值为x,y之和。例如,表达式max(add(1,2),7)的值为 阅读全文
posted @ 2013-08-08 12:04 心中的阿哲 阅读(243) 评论(0) 推荐(0)