#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef struct node
{
int data;
struct node *next;
};
typedef struct
{
struct node *front;
struct node *rear;
} LinkQueue;
InitQueue(LinkQueue *Q)
{
Q->front=(struct node *)malloc(sizeof( struct node));
Q->rear=Q->front;
Q->front->next=NULL;
}
EnQueue(LinkQueue *Q,int e)
{
struct node *p;
p=(struct node *)malloc(sizeof(struct node ));
p->data=e;
p->next=NULL;
Q->rear->next=p;
Q->rear=p;
}
DeQueue(LinkQueue *Q,int e)
{
struct node *p;
if(Q->front==Q->rear)
return 0;
else
{
p=Q->front->next;
Q->front->next=p->next;
if(p->next=NULL)Q->rear=Q->front;
return(p->data);
free(p);
}
}
OutputQueue(LinkQueue *Q)
{
struct node *p;
p=Q->front->next;
while(p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
}
GetFront(LinkQueue *Q)
{
struct node *p;
p=Q->front->next;
printf("%d",p->data);
}
void Fail(char str, int *next){ //KMP失败函数的编写。
int k = -1, j = 0;
while(j < strlen(str)){
if(k ==- 1 || str[j] == str[k]){
j++;
k++;
if(str[j] == str[k]) { //写的是失败函数,当匹配失败后要怎样跳转。
next[j] = next[k];
}else
next[j] = k;
}else {
k = next[k];
}
}
}
int KMP(string s1, string, s2, int pos){
int i = pos, j = 0;
int n = s1.size();
int m = s2.size();
while(i < len && j < m){
if(j == -1 || s1[i] == s2[j]){
i++;
j++;
}else
j = next[i];
}
}