链接http://acm.swust.edu.cn/problem/56/
汉明距离http://baike.baidu.com/view/725269.htm
#include <stdio.h> #include <string.h> int main() { int i,count; char str_1[105]; char str_2[105]; while(scanf("%s",str_1)&&str_1[0]!=‘X‘) { count=0; scanf("%s",str_2); for(i=0;i<strlen(str_1);i++) { if(str_1[i]!=str_2[i]) { count++; } } printf("Hamming distance is %d.\n",count); } return 0; }
时间: 2024-10-09 11:14:10