int Pattern(LinkList A, LinkList B)
{
LinkList C = (LinkList)malloc(sizeof(LinkList));
LNode *p, *q, *w, *u;
int flag;
p = A->next;
q = B->next;
while (p)
{
flag = 1;
u = p->next;
w = q;
while (q)
{
if (p->data != q->data)
{
flag = 0;
break;
}
else
{
p = p->next;
q = q->next;
}
}
if (flag)
{
return 1;
}
else
{
p = u;
q = w;
}
}
return 0;
}
已知序列AB,判断B是否为A的子序列
最新推荐文章于 2023-04-03 11:13:55 发布