The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
If so, I may need your help a bit in the next couple of days, it may help if you are immune to a guilty conscience!
> The Java version looks a lot less complicated :o)
Heh, that's Java for you. Or possibly my bad coding. The actual maths bit was pretty simple though, it's just formatting it for output to screen that looks messy.
I read the question again and my solution doesn't actually do everything it's supposed to - I didn't notice the '+ K' bit and so it doesn't deal with that. The question does seem to suggest that forming an array from the input is in one of the tutorial solutions so it shouldn't be too hard to adapt it.
Edit: just realised that this makes me look quite sad. I'm only staying in on a saturday doing C++ because I'm not feeling well. I swear!
Be sure you know what each bit does too just incase they decide to ask you why you used certain code or "what does this line do?"
> int polynomial[11];
> int derivative[10];
> int So if your polynomial was 4
> + 3x + 3x^2 + 4X^10 then the array polynomial should be
> [4,3,3,0,0,0,0,0,0,0,4]
> for (i=0; i<11; i++)
> cout << "Input coefficient for the X^" << i
> << " term: ";
> cin >polynomial[i];
> for (i=1; i<11; i++) //The first item in the polynomial is
> discarded so you start with i=1, the second element.
> derivative[i-1] = polynomial[i] * i
> for (i=0; i<10; i++)
> if (i==0)
> {cout << derivative[i]<< "
> ";}
> else
> if (derivative[i] < 0)
> {cout << derivative[i] <<
> "X^" << i << " ";}
> if (derivative[i] 0)
> {cout << "+" <<
> derivative[i] << "X^" << i << "
> If the polynomial you input is 4 + 3x + 3x^2 + 4X^10 then this gives
> you an output of 3 +6X^1 +40X^9, which if I remember my maths is what
> it should be :)
*head explodes*
The only bit I understand is the If statement.