关闭

POJ 1936 All in All(水~)

238人阅读 评论(0) 收藏 举报
分类:

Description
在第二个串中找第一个串
Input
多组输入,每组两个字符串,以文件尾结束
Output
对于每组输入,如果在第二个串中找到第一个串则输出Yes,否则输出No
Sample Input
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
Sample Output
Yes
No
Yes
No
Solution
简单字符串匹配
Code

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,len1,len2,flag;
    char s1[100002],s2[100002];
    while(scanf("%s",s1)!=EOF)
    {
        scanf("%s",s2);
        flag=0;
        len1=strlen(s1);
        len2=strlen(s2);
        if(len2>=len1)//第二个串不能比第一个串短 
        {
            j=0;
            for(i=0;i<len1;i++)//对于串一的每个字符在串二中找匹配 
            {
                for(;j<len2;j++)
                    if(s2[j]==s1[i])
                    {
                        flag++;
                        j++;
                        break;
                    }
            }
            if(flag==len1)//串一字符全部匹配 
                printf("Yes\n");
            else//串一字符不全匹配 
                printf("No\n");
        }
        else//串一比串二长,显然不满足条件 
            printf("No\n");
    }
    return 0;
}
0
0
查看评论

POJ-1936- All in All( 最长公共子序列 && 水题 )

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 30726   Accepted: 12815 ...
  • qq_16542775
  • qq_16542775
  • 2016-03-06 18:33
  • 275

POJ 1936:全在其中(All in All )

All in All Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 60000/30000K (Java/Other) Total Submission(s) : 14  ...
  • shouwang_tomorrow
  • shouwang_tomorrow
  • 2015-07-21 23:11
  • 752

[ACM] POJ 1936 All in All (查找,一个串是否在另一个串中)

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 27521   Accepted: 11266 Description Yo...
  • sr19930829
  • sr19930829
  • 2014-07-17 16:26
  • 1791

Poj 1936 All in All

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 29727   Accepted: 12369 Description You ...
  • Grit_ICPC
  • Grit_ICPC
  • 2015-08-10 10:05
  • 284

POJ 1936 All in All

DescriptionYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a cle...
  • qq_26525215
  • qq_26525215
  • 2015-10-23 18:42
  • 463

All in All(poj 1936)

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 27329   Accepted: 11176 Description You ...
  • u013486414
  • u013486414
  • 2014-06-07 00:07
  • 455

poj 1936 all in all

#include #include using namespace std; bool issubsequence(string str1,string str2){ int length1=str1.length(),length2=str2.length(); int j=0,i=0...
  • u010329739
  • u010329739
  • 2013-07-21 20:25
  • 337

【POJ 1936】All in All

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 30743   Accepted: 12827 ...
  • Torrance_ZHANG
  • Torrance_ZHANG
  • 2016-03-16 22:41
  • 172

POJ 1936 All in All

直接上代码吧   #include #include #include #include #include using namespace std; #define MAX 100001 char s1[MAX],s2[MAX]; int main() { while(scanf(&...
  • u011400953
  • u011400953
  • 2013-09-26 21:24
  • 798

POJ 1936 All in ALL

这题也是水题,暴力遍历0MS水过轻松加愉快。 不解释直接贴代码: #include #include int main() { char s1[100005],s2[100005]; while(scanf("%s",s1)!=EOF) { ...
  • lin375691011
  • lin375691011
  • 2013-08-14 09:56
  • 3689
    个人资料
    • 访问:545763次
    • 积分:24318
    • 等级:
    • 排名:第322名
    • 原创:1930篇
    • 转载:0篇
    • 译文:0篇
    • 评论:68条
    最新评论