hdu Train Problem I
这道题是道简单的栈模拟题,只要按照真实情况用栈进行模拟即可:
- #include<stdio.h>
- #include<string.h>
- #include<stack>
- using namespace std;
- int main()
- {
- int n, i, j, k, flag[];
- char s1[], s2[];
- stack <char> s;
- while(~scanf("%d %s%s",&n,s1,s2))
- {
- while(!s.empty()) s.pop(); //也可以不写这一句,把 stack <char> s; 就可以了
- memset(flag,-,sizeof(flag));
- j = k = ;
- for(i = ; i < n; i++)
- {
- s.push(s1[i]);
- flag[k++] = ;
- while(!s.empty() && s.top() == s2[j])
- {
- flag[k++] = ;
- s.pop();
- j++;
- }
- }
- if(j == n)
- {
- printf("Yes.\n");
- for(i = ; i < k; i++)
- {
- if(flag[i])
- printf("in\n");
- else
- printf("out\n");
- }
- }
- else
- printf("No.\n");
- printf("FINISH\n");
- }
- return ;
- }
hdu Train Problem I的更多相关文章
- hdu Train Problem I(栈的简单应用)
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...
- HDU Train Problem I (STL_栈)
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...
- HDU Train Problem I 1022 栈模拟
题目大意: 给你一个n 代表有n列 火车, 第一个给你的一个字符串 代表即将进入到轨道上火车的编号顺序, 第二个字符串代表的是 火车出来之后到顺序, 分析一下就知道这,这个问题就是栈, 先进后出吗, ...
- HDU 1022 Train Problem I
A - Train Problem I Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- hdu 1023 Train Problem II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...
- HDU 1022 Train Problem I(栈的操作规则)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...
- Train Problem I 分类: HDU 2015-06-26 11:27 10人阅读 评论(0) 收藏
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Hdu 1022 Train Problem I 栈
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1022.Train Problem I【栈的应用】【8月19】
Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very busy n ...
随机推荐
- ts tp 高清播放软件 Elecard MPEG Player 6.0.130827
Elecard MPEG Player 6.0.130827 计算机配置不高的情况下,流畅播放高清视频. 缺点是搜索时停顿严重. 包里有注册机. 下载地址 http://pan.baidu.com/s ...
- DP:Bridging Signals(POJ 1631)
不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...
- 获取4G以上的文件大小
1.DWORD dwFileSizeHigh; // 得到文件大小的高位 __int64 qwFileSize = GetFileSize(m_hSrcBigFile, &dwFileSi ...
- android 实现自定义卫星菜单
看了hyman老师的视频,听起来有点迷糊,所以就想把实现卫星菜单的实现总结一下.长话短说,下面总结一下: 一.自定义ViewGroup1).自定义属性文件 属性的定义: <attr name=& ...
- mysql多实例(个人的情况,不是大众的)里面有配置好的脚本+主从复制
[root@DB-S ~]# ll /usr/local/|grep mysql lrwxrwxrwx. 1 root root 21 Jun 14 01:52 mysql -> /alidat ...
- ubuntu 彻底删除卸载
1911 sudo apt-get install zabbix-agent 1916 sudo apt-get autoremove zabbix_agent root@(none):~# apt- ...
- 菜鸟学Linux命令:find命令 查找文件
find命令是Linux下最常用的命令之一,灵活的使用find命令,你会发现查找文件变得十分简单. 命令格式 find [指定查找目录] [查找规则(选项)] [查找完后执行的动作] 参数规则 - ...
- Android打Path的方法
转自:http://blog.csdn.net/xiangzi10/article/details/42710099 作为程序员,了解diff&patch命 令是非常必要的.比如说我们发现某个 ...
- Sql server之路 (五)插入多条数据
public bool GetDataUsingDataTaskReason(StationReasonCollection reason) { try { strCon.Open(); DateTi ...
- hdu 3183 贪心
题意:给一个数字,删掉其中的若干位,使得最后的数字最小 就是每次删除数的时候都是删掉第一个比右边数大的数 利用双向链表模拟 #include<cstdio> #include<ios ...