Topic:
Give a string of very long strings, asking for a string that matches the requirements, such as the destination string: 123
1******3***2, 12*****3, we need to find these.
In fact, it is similar to some harmonious system.
Analysis:
A natural match is one that matches each character in a match.
Set your to match string length bit n, the pattern length bit m.
The worst case for any character in the string to match is the M-time, which means that the character is not in the pattern string.
So the worst case scenario is m*n this match, and the time complexity is O (m*n)
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
Can be simple to achieve the following:
#include <iostream>
#include <string.h>
using namespace std;
void Search_str (char* src, char* DST)
{for
(int i=0; i < strlen (SRC); i++)
{
int j = 0;
for (j = 0; J < strlen (DST); j + +)
if (src[i] = = Dst[j]) break
;
if (J < strlen (DST))
cout << src[i];
else
cout << "*";
}
}
int main ()
{
char s[] = "12436781563";
Char d[] = "123";
Search_str (S, d);
return 0;
}
The output results are as follows:
12*3***1**3
Author: csdn Blog hhh3h