For this task, we will explore mutations that occur by substitution. Your task is to write a program called hamming.cpp that calculates the Hamming distance between two strings. Given two strings of equal length, the Hamming distance is the number of positions at which the two strings differ. e. g.: Hamming("aactgc", "atcaga") would output 3. Notice that certain amino acids are encoded by multiple codons. Therefore, not all substitutions result in a change of protein structure. The file <code class="language-plaintext highlighter-rouge" style="font-family: monospace, monospace; font-size: 1em; padding-left: 0.5em; padding-right: 0.5em; border-style: solid; border-width: 1px; border-radius: 0.5em; border-color: rgb(248, 248, 248); background: rgb(248, 248,
#include <iostream>
using namespace std;
int HammingDistance(char *s1, char *s2)
{
int i = 0, count = 0;
while (s1[i] != '\0')
{
if (s1[i] != s2[i])
count++;
i++;
}
return count;
}
int main()
{
char string1[100];
char string2[100];
cout<<"\nEnter the first string: ";
cin>>string1;
cout<<"\nEnter the second string: ";
cin>>string2;
cout << HammingDistance(string1, string2);
return 0;
}
Comments
Leave a comment