- 博客(8)
- 收藏
- 关注
原创 最优编辑距离问题
问题描述设A,B是两个字符串,用最少的字符操作将字符串A转换为字符串B,这里的字符操作包括删除一个字符,更改一个字符或者插入一个字符。而在这其中将字符串A转换为字符串B所用的最少的字符操作次数称为最优编辑距离。公式删除,d[i-1][j]+1;插入,d[i][j-1]+1;替换,if(a[i]==b[j]) d[i][j]=d[i-1][j-1] ,else d[i][j]=d[i-1][j-1]+
2016-11-20 13:09:29 901
原创 C语言随机产生字符串
#include"stdafx.h" #include <stdio.h> #include<time.h> #include <Windows.h> //产生长度为length的随机字符串 int genRandomString(int length, char* ouput) { int flag, i; srand((unsigned)time(NULL));
2016-11-20 13:06:12 1551 4
原创 简单背包问题
#include <stdio.h> int main() { int i, j, volume, n, f[100001] = {0}, weight[1000]; while (EOF != scanf("%d%d", &volume, &n)) { f[0] = 1; for (i = 0; i < n; i++)
2016-11-11 21:58:51 364
原创 俄罗斯农夫乘法(减治法)
#include <stdio.h> int Mul(int n, int m) { int sum = 0, a = 0; if (n == 0 || m == 0) return 0; if (n == 1) return m; while (n != 1) { if (n % 2 == 0)
2016-11-11 21:33:29 3518
原创 最近对问题
说明使用蛮力法,把所有点遍历一遍,找到最小#include<iostream> #include<iomanip> using namespace std; struct Point { double x, y; }point[1000];int main() { double min = 99999999; int n; cin >> n; for (int
2016-11-11 21:01:09 585
原创 模式匹配、字符串匹配(蛮力法)
**#include<iostream> #include<string> #include<algorithm> using namespace std; int StringMatch(string T,string s) { int n = T.size(); //文本长度 int m = s.size(); //模式长度 for (in
2016-11-11 20:47:12 1439
原创 选择排序相关问题
原理选择一个值array[0]作为标杆,然后循环找到除这个值外最小的值(查找小于标杆的最小值),交换这两个值,这时最小值就被放到了array[0]上,然后再将array[1]作为标杆,从剩下未排序的值中找到最小值,并交换这两个值。比冒泡排序减少交换次数。代码#include<iostream> #include<algorithm> using namespace std; void selects
2016-11-11 20:06:32 270
原创 Horner scheme问题
DescriptionIn numerical analysis, the Horner scheme or Horner algorithm, named after William George Horner, is an algorithm for the efficient evaluation of polynomials in monomial form. Horner’s method
2016-11-09 18:25:14 630
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人