struct ListNode *plusAB( struct ListNode *a, struct ListNode *b ) { struct ListNode node = {-1,NULL}, *tail = NULL; int jw = 0; tail = &node; while( a != NULL || b != NULL || jw != 0 ) { jw += a != NULL ? a->val : 0; jw += b != NULL ? b->val : 0; a = a != NULL ? a->next : a; b = b != NULL ? b->next : b; tail->next = (struct ListNode *) malloc( sizeof(*tail) ); tail->next->val = jw % 10; // 取余数. tail->next->next = NULL; tail = tail->next; jw = jw / 10; // 取商. } return node.next; }