-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.91 KB
(110%)
...xcodeproj/project.xcworkspace/xcuserdata/jalor.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ASM.cpp | ||
// ADT | ||
// | ||
// Created by Jalor on 2020/11/27. | ||
// Copyright © 2020 Jalor. All rights reserved. | ||
// | ||
|
||
#include "ASM.hpp" | ||
|
||
int min(int a,int b,int c){ | ||
if(a > b){ | ||
a = b; | ||
} | ||
if(a > c){ | ||
a = c; | ||
} | ||
return a; | ||
} | ||
|
||
int ASMClass::ASMCalcul(string p,string t){ | ||
int m = p.length(); | ||
int n = t.length(); | ||
int i,j; | ||
|
||
for (j = 0; j <= n; j++) | ||
{ | ||
D[0][j] = 0;//样本与文本有0处不同 | ||
} | ||
|
||
for (i = 0; i <= m;i++) | ||
{ | ||
D[i][0] = i;//样本与文本有i处不同 | ||
} | ||
|
||
for (j = 1; j <= n; j++) | ||
{ | ||
for (i = 1; i <= m; i++) | ||
{ | ||
if(p[i-1] == t[j-1]) {//若最后一个字符相等 | ||
D[i][j] = min(D[i-1][j-1], D[i-1][j]+1, D[i][j-1]+1);//样本i与文本j的最小差距应该产生在前方 | ||
//D[i-1][j-1];前字符串 比较的结果 | ||
//D[i-1][j];前 样本字符串 与 现 文本字符串 比较的结果 | ||
//D[i][j-1];现 样本字符串 与 前 文本字符串 比较的结果 | ||
} else {//若最后一个字符不相等 | ||
D[i][j] = min(D[i-1][j-1], D[i-1][j], D[i][j-1]) + 1;//样本i与文本j的最小差距应该产生在前方+1 | ||
} | ||
} | ||
//if(D[m][j] <= k)return j; | ||
} | ||
return D[m][n]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ASM.hpp | ||
// ADT | ||
// | ||
// Created by Jalor on 2020/11/27. | ||
// Copyright © 2020 Jalor. All rights reserved. | ||
// | ||
|
||
#ifndef ASM_hpp | ||
#define ASM_hpp | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
const int ASM_MAXN = 100; | ||
|
||
class ASMClass{ | ||
private: | ||
int D[ASM_MAXN][ASM_MAXN]; | ||
public: | ||
int ASMCalcul(string p,string t); | ||
}; | ||
|
||
#endif /* ASM_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters