# 线性表相关操作

void inverse(int a[], int n){
int t;
for(int i = 0; i < n; i ++){
t = a[i];
a[i] = a[n - i - 1];
a[n - i - 1] = t;
}
}


struct LNode{
int data;
struct LNode *next;
}LNode;

void deleteBetweenAandB(LNode *head, int a, int b){
LNode *q = head -> next;

bool flag = false;
while(q != NULL){
if(q -> data > a && !flag){
pmin = q;
premin = p;
flag = true;
}
else if(q -> data < b){
pmax = q;
premax = p;
}
p = p -> next;
q = q -> next;
}
premin -> next = pmax -> next;
}


void delete(LNode *head, int x){
p = p -> next;
while(p != NULL){
if(p -> data == x){
q = p;
p = q -> next;
free(q);
}
else  p = p -> next;
}
}


void invert(LNode *head){
LNode *p, *q, *r;
q = p -> next;
while(q != NULL){
r = q -> next;
q -> next = p;
p = q;
q = r;
}
}


struct LNode{
int data;
struct LNode *next;

minp = p;
while(p != NULL){
if(minp -> data > p -> data)
minp = p;
p = p -> next;
}
return minp;
}

else{
if(minp -> next == NULL){
while(p -> next != minp){
p = p -> next;
}
p -> next = NULL;
}
else{
while(p -> next != minp){
p = p -> next;
}
p -> next = minp -> next;
}
}
}


void merge(LNode *A, LNode *B, LNode *&C){
LNode *p = A -> next;
LNode *q = B -> next;
LNode *r;
C = A;
C -> next = NULL:
r = C;
while(p != NULL && q != NULL){
if(p -> data <= q -> data){
r -> next = p;
p = p -> next;
r = r -> next;
}
else{
r -> next = q;
q = q -> next;
r = r -> next;
}
}
r -> next = NULL;
if(p != NULL) r -> next = p;
if(q != NULL) r -> next = q;
}


void Interaction(Linklist &A, Linklist &B){
Linklist pc = A, pa = A -> next, pb = B -> next;
while(pa && pb){
if(pa -> data == pb -> data){
pc -> next = pa;
pc = pa;
pa = pa -> next;
pb = pb -> next;
}
else if(pa -> data > pb -> data){
pb = pb -> next;
}
else{
pa = pa -> next;
}
}
pc -> next = NULL:
return ;
}


void MoveMaxToTail(Linklist &head){
Linklist q = p -> next;
while(q != NULL){
if(p -> data < q -> data){
p = q;
}
q = q -> next;
}
while(r -> next != p){
r = r -> next;
}
while(q != NULL){
q = q -> next;
}
if(p -> next == NULL){
return ;
}
else{
r = next = p -> next;
p -> next = NULL;
q -> next = p;
}
}


void delele_non(Linklist &head, int x){
free(p);
}
else{
}
}


void delete(Linklist &head, int x){
while(p != NULL){
if(p -> data == x){
q = p;
p = p -> next;
pre -> next = p;
free(q);
}
else{
pre = p;
p = p -> next;
}
}
}


void sort(Linklist &head){
LNode *p = head -> next, *pre;
LNode *r = p -> next;
p -> next = NULL;
p = r;
while(p != NULL){
r = p -> next;
while(pre -> next != NULL && pre -> next -> data < p -> data){
pre = pre -> next;
}
p -> next = pre -> next;
pre -> next = p;
p = r;
}
}


bool hasCycle(Linklist &head){