#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ListNode *next) : val(x), next(next) {}
};
class Solution {
public:
ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
}
};
ListNode* createList() {
ListNode* list = new ListNode;
ListNode* listtemp = list;
while (1)
{
cout << "请输入节点的值" << endl;
cin >> list->val;
if (list->val == -1)
break;
list->next = new ListNode;
list = list->next;
list->next = nullptr;
}
cout << "链表生成完毕" << endl;
return listtemp;
}
void showList(ListNode* list)
{
ListNode* list2 = list;
while (list2->next != nullptr)
{
cout << list2->val << "->";
list2 = list2->next;
}
cout << "end" << endl;
}
int main()
{
ListNode* li = createList();
showList(li);
}