OJ clicks "sent crab and anemones" and oj "sent crab and anemones"

Source: Internet
Author: User

OJ clicks "sent crab and anemones" and oj "sent crab and anemones"

Description: The sender crab and anemone are a mutual partner. Anemones are the most competent guard for cancer. It uses toxic tentacles to sting all the animals that dare to come close to them and protect them. While the zombie crab carrying the difficult operation of anemones, four out of the food, there is a blessing to share.
However, not all sent crabs and anemones can work together. It depends on whether the body of anemone is in line with the shell of a zombie crab.
The body of anemone is wrinkled, and the shell of the zombie crab is also uneven. We can use A string consisting of uppercase letters to indicate their level, where A represents 0, B Represents 1, and so on. If the sum of the two values is 25, A and Z are the same, B is the same with Y, and so on.
As long as part of the sequence of the anemone body is consistent with the sequence of the sent crab shell, it is said that they can live together.
For example:
1. the folding of anemones is "ABCDEFG", and the zombie crab is "ZYXWVUT ". In this way, they can be completely consistent.
2. the folding of anemones is "AHBICJDKELFMGN" and the zombie crab is "ZYXWVUT ". In this way, the zombie crab can match part of the sequence "ABCDEFG" of Anemones (NOTE: Some sequences do not change the original sequence of characters, for example, "ACB" is not part of the sequence ).
3. the folding of anemones is "ABCD" and the zombie crab is "ZYXWVUT ". In this way, although anemones can be exactly the same as those in the previous section, they are smaller than those in mainland China and cannot completely protect the security of those in mainland China. None of them are suitable.
4. the folding of anemones is "HIJKLMNOPQ" and the zombie crab is "ZYXWVUT ". In this way, they are completely different.
Here we will give you two strings S1 and S2, representing the shells of anemone And the zombie crab respectively. To make them happy in the future, please help us calculate whether they match. The input includes multiple groups of test data. Each group of test data includes two strings: H and J, which represent the shell of anemone and the shell of the zombie crab respectively. It can be ensured that their length is less than 100000. The input ends with 0. Output "Yes" if the shell of the zombie crab and anemone can match, otherwise "No" is output ". Sample Input
ABCDEFG ZYXWVUTAHBICJDKELFMGN ZYXWVUTABCD ZYXWVUTHIJKLMNOPQ ZYXWVUT0 0
Sample output
YesYesNoNo
Prompt

The Code is as follows:

#include <iostream>#include <cstring>using namespace std;int main(){    int i,j,Lena,Lenb;    char a[100000],b[100000];    while (cin>>a>>b)    {        Lena=strlen(a);        Lenb=strlen(b);        if (a[0]!=0&&b[0]!=0&&Lena==1&&Lenb==1)            break;        else if (Lena>=Lenb)        {            for (i=0,j=0;i<Lena;i++)            {                if (a[i]+b[j]==155)                {                    j++;                }            }            if (j==Lenb)                cout<<"Yes"<<endl;            else                cout<<"No"<<endl;        }        else        {            cout<<"No"<<endl;        }    }    return 0;}


Running result:





Five angry mistakes, I don't know why, and I feel more and more weak.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.