-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (40 loc) · 1.46 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <locale>
#include <codecvt>
#include <functional>
#include <iterator>
#include "stringutil.hpp"
#include "matrix.hpp"
#include "Hirschberg_JS.cpp"
/**
* main method for the Hirschberg algorithm
* use hello and hallo as input for example. The longest common subsequence is hllo.
*/
int main(int argc, char **argv) {
std::string input1;
std::cout << "Enter first sequence : ";
std::cin >> input1;
std::string input2;
std::cout << "Enter second sequence : ";
std::cin >> input2;
using convert_t = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_t, wchar_t> strconverter;
std::wstring winput1 = strconverter.from_bytes(input1);
std::wstring winput2 = strconverter.from_bytes(input2);
auto *hirschberg = new Hirschberg_JS<std::wstring, wchar_t>(
// define predicate as Lambda expression
[](wchar_t a, wchar_t b) {
// possible extention for the extensibility of the function
// ö and o are handled equal as predicate example
return (a == 0xf6 && b == 0x6f) || (a == 0x6f && b == 0xf6) || a == b;
}
);
std::wcout << L"The longest common subsequence of " << winput1 << L" and " << winput2 << L" is "
<< hirschberg->hirschbergAlgoC(winput1.length(), winput2.length(), winput1, winput2) << std::endl;
delete hirschberg;
return 0;
}