//链表的中间节点:给定一个头结点为 head 的非空单链表,返回链表的中间节点。如果有两个中间节点,则返回第二个中间节点。
#include <iostream>
#include<vector>
using namespace std;
typedef struct L {
int v;
L* n;
L(int v):v(v),n(nullptr){}
}*l;
l z(l head) {
l slow = head;
l fast = head;
while (fast && fast->n) {
slow = slow->n;
fast = fast->n->n;
}
return slow;
}
int main() {
l a = new L(1);
l b = new L(2);
l c = new L(3);
l d = new L(4);
l f = new L(5);
a->n = b;
b->n = c;
c->n = d;
d->n = f;
f->n = nullptr;
l j = z(a);
cout << j->v;
return 0;
}