代码报错求助
我的代码:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
int c = 0;
ListNode* l3 = new ListNode;
l3->next=nullptr;
while (l1 || l2)
{
int sum = 0;
sum=l1->val + l2->val+c;
if (sum > 9)
{
sum = sum % 10;
c = 1;
ListNode* s = (ListNode*)malloc(sizeof(ListNode));
s->val = sum;
l3->next = s;
l3 = s;
}
else { c = 0;
ListNode* s = (ListNode*)malloc(sizeof(ListNode));
s->val = sum;
l3->next = s;
l3 = s;
}
l1 = l1->next;
l2 = l2->next;
}
return l3;
}