In: Computer Science
In C++
Write a function called findMatchedGenome that takes three genomes and a sequence and prints the list of matched genomes
Checking these cases must be performed in the order specified
above. First check for empty genomes and sequence followed by a
check for different lengths.
Helper functions (the functions used in your
findMatchedGenome) should be written in the answer
box as well.
For example:
Test | Result |
---|---|
//For empty sequence findMatchedGenome("TTC","GCC","TCT",""); |
Genomes or sequence is empty. |
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void findMatchedGenome(string genome1,string genome2,string
genome3,string seq);
int main(void) {
//Declaring variables
findMatchedGenome("TTC","GCC","TCT","");
return 0;
}
void findMatchedGenome(string genome1,string genome2,string
genome3,string seq)
{
if(genome1.compare("")==0 ||
genome2.compare("")==0||genome3.compare("")==0||
seq.compare("")==0)
{
cout<<"Genomes or sequence is
empty."<<endl;
}
else if(genome1.length()!=genome2.length() ||
genome2.length()!=genome3.length() ||
genome3.length()!=genome1.length())
{
cout<<"Lengths of genomes are
different."<<endl;
}
else
{
if(genome1.compare(seq)==0)
{
cout<<"Genome1 is
matched to sequence."<<endl;
}
else if(genome2.compare(seq)==0)
{
cout<<"Genome2 is
matched to sequence."<<endl;
}
else if(genome3.compare(seq)==0)
{
cout<<"Genome3 is
matched to sequence."<<endl;
}
else
{
cout<<"No Genome is
matched to sequence."<<endl;
}
}
}
___________________________
Output:
____________________________Thank You