Quadratic Equation check problem

Back to General discussions forum

GeorgySerga     2015-11-12 16:01:30

I did solve the #38 ‐ Quadratic Equation problem, but the answer is said to be wrong. I believe I should not provide my code but the output example is:

// 15
// 5 -5 -10
// 8 160 1088
// 3 -15 -150
// 8 -96 800
// 4 -4 -224
// 7 28 371
// 7 -98 595
// 8 80 328
// 8 -72 144
// 1 10 25
// 7 28 -35
// 6 48 696
// 7 -98 518
// 5 90 450
// 5 -10 -120

// 2 -1;
// -10+6i -10-6i;
// 10 -5;
// 6+8i 6-8i;
// 8 -7;
// -2+7i -2-7i;
// 7+6i 7-6i;
// -5+4i -5-4i;
// 6 3;
// -5 -5;
// 1 -5;
// -4+10i -4-10i;
// 7+5i 7-5i;
// -9+3i -9-3i;
// 6 -4

What am I missing? I have all the output numbers in one line with one space between them. Thank you.

Quandray     2015-11-12 16:50:03
User avatar

When I try your code with your test data, the output I get is

2 -1; -10+6i -10-6i; 10 -5; 6+8i 6-8i; 8 -7; -2+7i -2-7i; 7+6i 7-6i; -5+4i -5-4i; 6 3; -5; 1 -5; -4+10i -4-10i; 7+5i 7-5i; -9+3i -9-3i; 6 -4;

The tenth answer is a single value "-5"! Also, I don't know whether the final ";" will cause a problem, but the example doesn't have a ";" at the end.

Rodion (admin)     2015-11-12 19:05:43
User avatar

>I believe I should not provide my code

Yes, it could be seen by the link "unsuccessful solutions" from your profile, so we need not a copy here. This is the direct link - though it is visible only to you and to people who already solved the problem.

As about output format - thanks to Quandray about pointing these issues - it looks like:

  • if two roots are identical, they are printed both anyway, e.g. -5 -5 - I'll add this to problem statement right now;
  • there should be no trailing semicolon (;).

Hope this helps and I'm not mistaken myself...

GeorgySerga     2015-11-13 06:48:59

The tenth answer is a single value "-5"!

Yes, that's because I did one more 'else' to test, the answer I gave has two equal roots.

The problem was with the trailing semicolon. Thank you for your help.

Please login and solve 5 problems to be able to post at forum