Добавил:
itan_hunt
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:lab5 / main
.cpp#include "KMP.h"
#include "unitTesting.h"
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char const *argv[]) {
if (argc == 2) {
if (!strcmp("-kmp", argv[1])) {
string text, pattern;
cin >> pattern >> text;
std::vector<lli> sol = KMP(text, pattern);
if (sol.empty()){
cout << (-1) << endl;
} else {
for (lli i = 0, s = sol.size() - 1; i < s; i++) {
cout << sol[i] << ",";
}
cout << sol[sol.size() - 1] << endl;
}
} else if (!strcmp("-shift", argv[1])) {
string text, pattern;
cin >> pattern >> text;
cout << findFirstCyclicShift(text, pattern) << endl;
} else if (!strcmp("-test", argv[1])) {
runUnitTestingLabKMP();
}
} else {
cout << "You forgot a flag or input more than one flag or your flag is incorrect.\n"
"Don't worry.\nRead README.txt and try again." << endl;
}
return 0;
}