150题 2.5
ListNode* AddList(ListNode* root1, ListNode* root2,int& carry){
if (root1==NULL && root2==NULL)
return NULL;
ListNode* result = AddList(root1->next,root2->next,carry);
ListNode* temp = NULL;
temp = new ListNode(0);
temp->val = (root1->val+root2->val+carry)%10;
carry = (root1->val+root2->val+carry)/10;
temp->next = result;
return temp;
}
ListNode* PadList(ListNode* root,int length){
if (length==0)
return root;
ListNode* temp = new ListNode(0);
temp->next = root;
return PadList(temp,length-1);
}
ListNode* AddList(ListNode* root1, ListNode* root2){
if (root1==NULL && root2==NULL)
return NULL;
if (root1==NULL)
return root2;
if (root2 == NULL)
return root1;
int len1=0;
ListNode* temp = root1;
while(temp!= NULL){
len1++;
temp =