Hamming Distance

Hamming distance between two binary strings of equal length is the number of mismatches between every corresponding positions of the two strings. Suppose A = “01001” and B = “11000” then the Hamming Distance between A and B is 2 because they only mismatch in position 1 and 5 (1- based indexing).


This is a companion discussion topic for the original entry at https://toph.co/p/hamming-distance

#include<bits/stdc++.h>
using namespace std;

int main()
{
int n,m,sum=0,c=0,j=0,k=0;
cin >> n >> m;int l=m;
char s[n],ss[m];
cin >> s >> ss;
while(m<=n)
{
for(int i=j,k=0;i<m,k<l;i++,k++)
{
if(s[i]!=ss[k])c++;
}
sum+=c;
j++;m++;c=0;
}
cout<<sum<<endl;
sum=0;c=0;
}

///What is problem?