Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is what I have currently: int main() { char answer = 'y'; do{ string s1, s2; cout cin >> s1 >> s2; int same

image text in transcribed

Here is what I have currently:

int main()

{

char answer = 'y';

do{

string s1, s2;

cout

cin >> s1 >> s2;

int same = 0;

int s2length = s2.length();

int s1length = s1.length();

int length = s2length - 1;

for (int i = 0; i

{

for (int j = 0; j

{

if (s1.at(i) == s2.at(j))

{

same++;

length-=1;

i++;

cout

}

}

}

cout

cout

cout

cin >> answer;

}

while (answer == 'y');

return 0;

}

Problem A: (A Type of) Sequence Matching (20 points) One string analysis task that played a crucial role in mapping the human genome is the following: given two strings s1 and s2, find the largest substring occurring at both the very beginning of s1 and the very end of s2. For example, if s1 is the string ACTTTCTAT and s2 is the string TGTGTTTTGAAAAAACT, notice that ACT occurs at the beginning of s1 and the end of s2. Moreover, no longer substring occurring at the beginning of s1 also occurs at the end of s2: for example, the first four characters of s1, namely ACTT, are not the final four characters of s2; the first five characters of s1, namely ACTTT, are not the final five characters of s2; and so on. Write a C++program that does the following: 1. Asks the user to input the two strings s1 and s2. 2. Finds the longest substring that occurs both at the beginning of s1 and the end of ??. 3. Prints out that substring and its length. . Has a continuation loop, so the user can repeat the above steps as many times as he or she likes Here are additional comments and requirements Do not make any assumptions about the strings' lengths. In particular, the two strings might have different lengths. Your program should store the strings as C++-style strings You may use any of the string class functions mentioned in the textbook. Your solution should not be a long program, but think carefully about the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions