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