-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
67 lines (60 loc) · 1.93 KB
/
test.cpp
File metadata and controls
67 lines (60 loc) · 1.93 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include <sstream>
#include <string>
#include<cmath>
void get_next(int next[], std::string pattern)
{
int length = pattern.length();
int j = 0, k = -1;
next[1] = 0;
while(j < length){
if(k == -1 || pattern[k] == pattern[k]){
k++;
j++;
next[j] = k;
}
else{
k = next[k];
}
}
}
int kmp(std::string S, std::string T)
{
int next[30] = {0};
int slen = S.length(), tlen = T.length();
int i = 0, j = -1;
while(i < slen && j < tlen){
if(S[i] == T[j] || j == -1){
i++; j++;
}
else{
j = next[j];
}
}
if(j >= tlen){
return i - tlen;
}
else{
return -1;
}
}
void menu()
{
std::cout << "################################### MENU ########################################" << std::endl;
std::cout << "## --------------------请根据操作输入相应的命令或数字------------------- ##" << std::endl;
std::cout << "## *********** 0.Exit(退出) *********** ##" << std::endl;
std::cout << "## *********** 1.LoadHTML(加载HTML文件) *********** ##" << std::endl;
std::cout << "## *********** 2.CheckHTML(检查HTML代码合法性) *********** ##" << std::endl;
std::cout << "## *********** 3.OutHTML(输出XPATH路径下的代码) *********** ##" << std::endl;
std::cout << "## *********** 4.OutText(输出XPATH路径下的文本) *********** ##" << std::endl;
std::cout << "## *********** 5.URLParser(解析URL) *********** ##" << std::endl;
std::cout << "#################################################################################" << std::endl;
}
int main()
{
menu();
return 0;
}