ListNode* createList()
{
ListNode* head = (ListNode*)malloc(sizeof(ListNode));
ListNode *p, *q;
q = head;
int val;
while (1)
{
cin >> val;
if (val == -1)
{
break;
}
p = (ListNode*)malloc(sizeof(ListNode));
p->val = val;
q->next = p;
q = p;
}
q->next = NULL;
return head->next;
}
建立链表
最新推荐文章于 2024-02-23 18:48:16 发布