I need ideas for the homework that I have. Consider the following definition:
typedef struct listNode {
int* dataPtr;
struct listNode* next;
} ListNode;
typedef struct list {
ListNode* head;
ListNode* tail;
} List;
Each node list is a single digit. Each number is represented by a list, but in the reverse order: the last digit of the number is the first list β the list node, and the first digit of the number β the last list β the list node.
I wrote a function
void addNumbers(List n1, List n2, List *sum);
which returns a new list with the sum of two other lists.
Now I have to write a function to multiply:
void multNumbers(List n1, List n2 , List* prod);
And Iβm kind of stuck in how to implement it. This is not about code, but how to do it. Needless to say, we are not allowed to convert the numbers to an integer, multiply and convert the result to a list.
Any help would be greatly appreciated.
Thank.