Poj 1396All in All

Source: Internet
Author: User

Start string today! This is a simple string question. In fact, the simple question of the competition generally involves string processing.

Question: enter two strings to determine whether the last one is composed of the previous inserted characters. If "Yes" is output, otherwise "No" is output ".

Analysis: you only need to compare two strings from the beginning. If the string is s [I] = t [j], I ++, j ++; otherwise, j ++. It ends at the end of any string. If the end condition is s, "yes" is output; otherwise, "no" is output ".

 

Code:

[Cpp]
<Span style = "font-family: KaiTi_GB2312; font-size: 18px;" >#include <iostream>
Using namespace std;
Char s [100001], t [100001];
Int judge (char s [], char t [])
{
Int I = 0, j = 0;
While (s [I]! = '\ 0' & t [j]! = '\ 0 ')
{
If (s [I] = t [j])
{
I ++;
J ++;
}
Else j ++;
}
If (s [I] = '\ 0') return 1;
Else return 0;
}
Int main ()
{
While (cin> s> t)
{
If (judge (s, t) cout <"Yes" <endl;
Else cout <"No" <endl;
}
Return 0;
}
</Span>

 


Author: hellobabygogo3

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.