0

Hi,

Suppose I have a character array with the elements B,A,A. Now I have another character array with the elements A,B,B,B,A,A. How do I match the pattern B,A,A of the first character array with that of the second character array so as to produce the following output:
A B B B A A
- - - B A A
In other words, if a pattern is detected, the letters in a character array not matching any characters of the other array will have a dash underneath as shown.

I will really appreciate if somebody suggests some codes in C++.
Thanks

5
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by carnage
0

Hi,

I am able to solve my problem using find() only if I know the length of the pattern. Is there a way to find the length of the pattern?

Any help much appreciated.

Thanks

0

Suppose I have one character array as A,B,B,B,A,A,B and another character array as A,B,A,A,A. Now using find () I can find the second string matches the first where the pattern starts at B,A,A. Suppose I dont know the pattern. Using find() I can only find the match location but how do I find the length of the pattern? It may be mentioned that I take the two strings as input from the key board and for the given example, the output should be:

A B B B A A B
A - - B A A A


Any help much appreciated

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.