Virus DNA files As a future doctor, Jojo works in a laboratory that analyzes viral DNA. Due to the pandemic During the virus outbreak, Jojo received many requests to analyze whether there was any viral DNA in the patient. This number of requests made Jojo's job even more difficult. Therefore, Jojo ask Lili who is a programmer for help to make a program that can read the file containing the patient's DNA data and viral DNA and then match them. If on the patient's DNA found the exact same string pattern, then write to the index screen the found DNA. Data contained in the file testdata.in Input Format The first line of input is the number of test cases T The second row and so on as many as T rows are the S1 string of patient DNA and the S2 string of viral DNA separated by spaces Output Format The array index found the same string pattern. Constraints 1 ≤ T ≤ 100 3 ≤ |S2| ≤ |S1| ≤ 100 |S| is the length of the string. S will only consist of lowercase letters [a-z] Sample Input (testdata.in) 6 abbab ab cdefgh def pxzzt xyz ijklijkl ijkl kjldfjdlsjf nnn icumeyb oeibv Sample Output 0 2 4 1 N/A 0 4 N/A N/A Sample Input 3 zzzz zz xoxozy bc oqryc yc Sample Output 0 1 N/A 3 In the sample above, for example input: ababab ab then the string pattern 'ab' is found at index 0, 2 and 4 zzz zz then the string pattern 'zz' is found at index 0 and 1 oqryc yc then the string pattern 'yc' is found at index 3 Notes Even though it wasn't stated in the problem, by now you should know that the advantages spaces or lines are considered WRONG ANSWER.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Virus DNA files

As a future doctor, Jojo works in a laboratory that analyzes viral DNA. Due to the pandemic During the virus outbreak, Jojo received many requests to analyze whether there was any viral DNA in the patient. This number of requests made Jojo's job even more difficult. Therefore, Jojo ask Lili who is a programmer for help to make a program that can read the file containing the patient's DNA data and viral DNA and then match them. If on the patient's DNA found the exact same string pattern, then write to the index screen the found DNA. Data contained in the file testdata.in

Input Format

The first line of input is the number of test cases T
The second row and so on as many as T rows are the S1 string of patient DNA and the S2 string of viral DNA separated by spaces

Output Format

The array index found the same string pattern.

Constraints

1 ≤ T ≤ 100
3 ≤ |S2| ≤ |S1| ≤ 100
|S| is the length of the string.
S will only consist of lowercase letters [a-z]

Sample Input (testdata.in)

6
abbab ab
cdefgh def
pxzzt xyz
ijklijkl ijkl
kjldfjdlsjf nnn
icumeyb oeibv

Sample Output

0 2 4
1
N/A
0 4
N/A
N/A

Sample Input

3
zzzz zz
xoxozy bc
oqryc yc

Sample Output

0 1
N/A
3

In the sample above, for example input:
ababab ab then the string pattern 'ab' is found at index 0, 2 and 4
zzz zz then the string pattern 'zz' is found at index 0 and 1
oqryc yc then the string pattern 'yc' is found at index 3

Notes

Even though it wasn't stated in the problem, by now you should know that the advantages spaces or lines are considered WRONG ANSWER.

Expert Solution
Step 1

//note no programming language is mentioned so I was written in c++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
        {
    string s,s1;
    cin>>s>>s1;
    int l=s.size(),l1=s1.size();
        int h=0;
    for(int i=0;i<=l-l1;i++)
        {
           
            string k="";
            for(int j=i;j<(i+l1);j++)
            {
                k+=s[j];
            }
            if(k==s1){
            cout<<i<<" ";
                h=1;}
        }
        if(h==0)
        cout<<"N/A"<<endl;
       
    else
    cout<<endl;
        }
}

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education