zoukankan      html  css  js  c++  java
  • UVA 10340 (13.08.25)

    Problem E

    All in All

    Input: standard input

    Output: standard output

    Time Limit: 2 seconds

    Memory Limit: 32 MB

    You have devised a new encryption technique whichencodes a message by inserting between its characters randomly generatedstrings in a clever way. Because of pending patent issues we will not discussin detail how the strings are generated and inserted into the original message.To validate your method, however, it is necessary to write a program thatchecks if the message is really encoded in the final string.

    Given two strings s and t, you haveto decide whether s is a subsequence of t, i.e. if you can removecharacters from t such that the concatenation of the remainingcharacters is s.

    Input Specification

    The input contains several testcases. Each isspecified by two strings s, t of alphanumeric ASCII characters separatedby whitespace. Input is terminated by EOF.

    Output Specification

    For each test case output, if s is asubsequence of t.

    Sample Input

    sequence subsequence
    person compression
    VERDI vivaVittorioEmanueleReDiItalia
    caseDoesMatter CaseDoesMatter

    SampleOutput

    Yes
    No
    Yes
    No


    题意:

    在字符串2中找字符串1


    然后, 其实我不想说思路了


    直接贴AC代码:

    #include<stdio.h>
    #include<string.h>
    
    char str1[100005];
    char str2[100005];
    
    int main() {
        while(scanf("%s %s", str1, str2) != EOF) {
            int len1, len2;
            len1 = strlen(str1);
            len2 = strlen(str2);
            int i;
            int mark = 0;
            int pos = 0;
            for(i = 0; i < len2; i++) {
                if(str1[pos] == str2[i]) {
                    pos++;
                    if(pos >= len1)
                        mark = 1;
                }
            }
            if(mark)
                printf("Yes
    ");
            else
                printf("No
    ");
        }
        return 0;
    }


  • 相关阅读:
    用递归获取文件夹以及子文件夹下的所有文件
    C#导入XLS数据到数据库
    张老师生日问题 c# CopyRight: http://blog.moozi.net/
    convert.cpp
    C#中判断扫描枪输入与键盘输入
    C# 执行多条SQL语句,实现数据库事务(通过Hashtable存储数据) .
    GridView 根据多个字段值删除
    泛型入门
    TreeView 控件应用
    事务控制案例(一)
  • 原文地址:https://www.cnblogs.com/pangblog/p/3283456.html
Copyright © 2011-2022 走看看