| 29 | struct ListNode* next; |
| 30 | }Node, * PNode; |
| 31 | Node* initLink() { |
| 32 | Node* p = (Node*)malloc(sizeof(Node));//创建一个头结点 |
| 33 | Node* temp = p;//声明一个指针指向头结点,用于遍历链表 |
| 34 | for (int i = 1; i < 10; i++) { |
| 35 | Node* a = (Node*)malloc(sizeof(Node)); |
| 36 | a->Element = i; |
| 37 | a->next = NULL; |
| 38 | temp->next = a; |
| 39 | temp = temp->next; |
| 40 | } |
| 41 | return p; |
| 42 | } |
| 43 | void display(Node* p) { |
| 44 | Node* temp = p;//将temp指针重新指向头结点 |
| 45 | while (temp->next) { |