![]() |
|
#1
|
|||
|
|||
Linked ListMy problem:The overloaded += function which is supposed to add two polynomials only works when both linked lists are the same length and if the exponents are the same. I need real help and I am desperate. Please anyone who can throw me a bone here please jump in.
CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: Linked ListA few points:
1) I can't see where you actually add the coefficients, just where you print out what would have been the result. 2) It doesn't look like you handle the case that p1 has exponents that "this" doesn't have. In that case, you need to add the new exponent to "this". |
|
#3
|
|||
|
|||
Quick linked list problemThe problem comes in the += overloaded operator. Everything works well unless as an example I enter one list as +4x^5 and the other list as +3x^4+2x^2 then the only output I get is the first list repeating twice. Please throw me some help here.
CPP / C++ / C Code:
Last edited by admin : 29-Apr-2009 at 00:41.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#4
|
|||
|
|||
Re: Quick linked list problemThis is just a continuation of the other thread. There is not a need to create another.
For each TermType in p1, find the same exponent in "this". If it exists, add the coefficient from p1's TermType to the coefficient of this's TermType. If it doesn't exist, insert p1's TermType to this. After doing this for each TermType, you should go through this's TermTypes and remove any with a coefficient of zero. I can't make it any clearer without writing the code myself. |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Str_Misaligned in Double Link List | Peter_APIIT | C Programming Language | 1 | 29-Feb-2008 21:50 |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 08:44 |
| Linked list: differing results on same code. | Howard_L | C Programming Language | 17 | 29-Jun-2007 00:36 |
| search linked list | itsmecathys | C++ Forum | 20 | 18-Apr-2005 02:34 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The