简单的字符串比较题 POJ 1936
Description
Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
Input
Output
Sample Input
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
Sample Output
Yes
No
Yes
No
#include<iostream>
#include<string.h>
using namespace std;
int main(long i,long j)
{
char s[100000],t[100000];
while(cin>>s>>t)
{
long lens=strlen(s);
long lent=strlen(t);
i=0;
j=0;
while(true)
{
if(i==lens)
{
cout<<"YES"<<endl;
break;
}
if(j==lent)
{
cout<<"NO"<<endl;
break;
}
if(s[i]==t[j])
{
i++;
j++;
}
else j++;
}
memset(s,'\0',lens);
memset(t,'\0',lent);
}
return 0;
}
这是一道简单题,只需比较就行了,当s串存在t串中时,输出YES;否则输出NO
最新文章
- c#面向对象基础技能——学习笔记(二)基于OOP思想研究对象的【属性】
- Ubuntu常用软件安装
- jQuery的Dom插入操作图示
- Windows Server 2008 64 位 IIS7.5 ASP.NET MVC4 发布问题
- C语言接口与实现实例
- android 学习随笔八(异常处理总结)
- Linux下查看文件权限、修改文件权限的方法
- http://www.imooc.com/video/4767 zepto教学视频笔记
- 读书笔记 |Google C++编程风格指南
- [React] Styling a React button component with Radium
- 扑克k,你知道的人物吗?
- .NET中的IO操作之文件流(一)
- 如何检测被锁住的Oracle存储过程及处理办法汇总(转)
- 基于JAVA语言的selenium测试基础总结
- 【NIO】Java NIO之选择器
- @@ITENTITY
- ps去掉图片上的文字
- Python By 360、小米
- 使用 mod_rewrite 来修改 Confluence 6 的 URLs
- spring的官方文档地址