1. #include<stdio.h>
  2. #include<stack>
  3. #include<string.h>
  4. #define N 20
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. stack<char>S;
  11. int n, i, j, k, a[N];
  12. char s1[N], s2[N];
  13. while(scanf("%d", &n) != EOF)
  14. {
  15. while(!S.empty())//清空栈
  16. S.pop();
  17. scanf("%s%s", s1, s2);
  18. j = k = ;
  19. memset(a, , sizeof(a));
  20. for(i = ; i < n ; i++)
  21. {
  22. S.push(s1[i]);//入栈
  23. a[k++] = //进栈标记
  24. while(!S.empty() && S.top() == s2[j])//栈首相同
  25. {
  26. a[k++] = ;//出栈标记
  27. S.pop();//出栈
  28. j++;//j右移
  29. }
  30. }
  31. if(j == n)
  32. {
  33. printf("Yes.\n");
  34. for(i = ; i < k ; i++)
  35. if(a[i] == )
  36. printf("in\n");
  37. else
  38. printf("out\n");
  39. }
  40. else
  41. printf("No.\n");
  42. printf("FINISH\n");
  43. }
  44. return ;
  45. }

栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022的更多相关文章

  1. HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...

  2. KMP(http://acm.hdu.edu.cn/showproblem.php?pid=1711)

    http://acm.hdu.edu.cn/showproblem.php?pid=1711 #include<stdio.h> #include<math.h> #inclu ...

  3. HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632

    http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...

  4. 待补 http://acm.hdu.edu.cn/showproblem.php?pid=6602

    http://acm.hdu.edu.cn/showproblem.php?pid=6602 终于能够看懂的题解: https://blog.csdn.net/qq_40871466/article/ ...

  5. HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702

    #include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...

  6. HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257

    Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...

  7. http://acm.hdu.edu.cn/showproblem.php?pid=2579

    #include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...

  8. KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594

    riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...

  9. HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544

    //代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...

随机推荐

  1. CF 366E Dima and Magic Guitar(最远哈密顿距离)

    题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的 ...

  2. MyBatis学习总结3-优化MyBatis配置文件

    连接数据库配置优化 可以将数据库连接配置信息卸载conf.xml中,但是为了优化连接,专门写一个properties用于存数据库连接信息,然后在conf.xml中进行引用,里面包括数据库驱动,地址,用 ...

  3. Java关键字static、final使用小结

    static  1. static变量     按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...

  4. open_table

    /* Open a table. SYNOPSIS open_table() thd Thread context. table_list Open first table in list. acti ...

  5. 函数xdes_init

    /**********************************************************************//** Inits an extent descript ...

  6. EASYUI+MVC4通用权限管理平台

    通用权限案例平台在经过几年的实际项目使用,并取得了不错的用户好评.在平台开发完成后,特抽空总结一下平台知识,请各位在以后的时间里,关注博客的更新. 1.EASYUI+MVC4通用权限管理平台--前言 ...

  7. bzoj1567: [JSOI2008]Blue Mary的战役地图

    将矩阵hash.s[0]忘了弄成0,输出中间过程发现了. hash.sort.判重.大概这样子的步骤吧. #include<cstdio> #include<cstring> ...

  8. bzoj1863: [Zjoi2006]trouble 皇帝的烦恼

    白书原题.l边界又设错啦.一般都是错这里吧.注意为什么这里不能是l=0.(只是为了判断第一个和最后一个 #include<cstdio> #include<cstring> # ...

  9. Android development tools line_endings hacking

    /******************************************************************** * Android development tools li ...

  10. Java [Leetcode 257]Binary Tree Paths

    题目描述: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tr ...