Write a program to find hamming distance
Practical - 5
Write a program to find hamming distance. For example Hamming distance d(v1,v2)=3 if v1=011011,v2=110001.
Code:
Write a program to find hamming distance. For example Hamming distance d(v1,v2)=3 if v1=011011,v2=110001.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,len1,len2,count=0;
char one[200],two[200];
clrscr();
while(1)
{
printf("Enter 1st string:\n");
scanf("%s",&one);
printf("Enter 2nd string:\n");
scanf("%s",&two);
len1=strlen(one);
len2=strlen(two);
if(len1!=len2)
{
printf("\nLength of both strings must be same, enter again!\n");
}
else
{
for(i=0;i<len1;i++)
{
if(one[i]!=two[i])
{
count++;
}
}
break;
}
}
printf("\nHamming distance:\t%d",count);
getch();
}
Output:#include<conio.h>
#include<string.h>
void main()
{
int i,len1,len2,count=0;
char one[200],two[200];
clrscr();
while(1)
{
printf("Enter 1st string:\n");
scanf("%s",&one);
printf("Enter 2nd string:\n");
scanf("%s",&two);
len1=strlen(one);
len2=strlen(two);
if(len1!=len2)
{
printf("\nLength of both strings must be same, enter again!\n");
}
else
{
for(i=0;i<len1;i++)
{
if(one[i]!=two[i])
{
count++;
}
}
break;
}
}
printf("\nHamming distance:\t%d",count);
getch();
}
error: conio.h: No such file or directory
ReplyDelete#include
^~~~~~~~~
compilation terminated.
show above error
Poker Review - JMHub
ReplyDeletePoker from JAMOKEE Casino is an exclusive 김제 출장마사지 online poker room 의정부 출장안마 for all US players. 대전광역 출장샵 Enjoy a range of games from Roulette to Blackjack, and the best 전라북도 출장마사지 of the 속초 출장마사지 best