计算字符串的相似度
来源:互联网 发布:sci影响因子查询数据库 编辑:程序博客网 时间:2024/05/16 16:54
#include <stdio.h>
#include <stdlib.h>
int minValue(int a, int b, int c)
{
int min = ((a < b) ? a : b) < c ? ((a < b) ? a : b) : c;
return min;
}
int CalculateStringDistance(char* strA, int pABegin, int pAEnd, char* strB, int pBBegin, int pBEnd)
{
if(pABegin > pAEnd)
{
return 0;
}
else
{
return pBEnd - pBBegin + 1;
}
if(pBBegin > pBEnd)
{
if(pABegin > pAEnd)
{
return 0;
}
else
{
return pAEnd - pABegin + 1;
}
}
if(strA[pABegin] == strB[pBBegin])
{
return CalculateStringDistance(strA, pABegin + 1, pAEnd, strB, pBBegin + 1, pBEnd);
}
else
{
int t1 = CalculateStringDistance(strA, pABegin, pAEnd, strB, pBBegin + 1, pBEnd);
int t2 = CalculateStringDistance(strA, pABegin + 1, pAEnd, strB, pBBegin, pBEnd);
int t3 = CalculateStringDistance(strA, pABegin + 1, pAEnd, strB, pBBegin + 1, pBEnd);
return minValue(t1, t2, t3) + 1;
}
}
int main()
{
char * strA = "abcdefg";
char * strB = "abcdef";
int distance = CalculateStringDistance(strA, 1, 7, strB, 1, 6);
//int m = minValue(1, 2, 3);
printf("min = %d\n",distance);
return 0;
}
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度。
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 计算字符串的相似度
- 给CSDN博客添加代码运行框,兼容FireFox!
- 无法为数据库 'tempdb' 中的对象分配空间,因为 'PRIMARY' 文件组已满
- BeanUtils.copyProperties与PropertyUtils.copyProperties用法及区别
- 从无头单链表中删除节点
- 备忘:centos+was6.1关于编码的七七八八
- 计算字符串的相似度
- Linux下卸载vmware
- 基于ExtJs的desktop桌面化框架。(仿京东后台管理系统)
- ajax 验证用户名是否存在
- Linux内核编译 Erro:Unable to find the ncurses libraries
- 重建二叉树
- POI 操作EXCEL
- C#窗口和程序的退出
- 一步一步使用POI做java报表