December 17, 2018
Quadratic equation 2
Threads: Let programmers program the quadratic equation 2: with a, b, c typing.
Input: A line of 3 numbers separated by spaces.
Output: Print out the case.
1/ “VSN” – If equations infinitely many solutions
2/ “VN” – If the equation has no solution
3/ “x = 2.00” – If the equation has a solution (experience 2).
4/ If equation 2 experience, in 2 That experience in one line and separated by spaces. Little experience in front, large experience in the following.
The experience is rounded to 2 decimal.
For example:
input: 1 -2 1 output: x = 1.00
You are not logged in? Log in to Submit Now!
61 Comments
Add a Comment
You must be logged in to post a comment.
My post code is correct, run correctly but why test case has problem. Could you please review the test case for me?.
1. Wrong Answer
Test Input:
1 2 1
Test Output:
x = -1.00
Your Output:
x = -1.00
2. Accepted
3. Accepted
4. Wrong Answer
Test Input:
2 4 2
Test Output:
x = -1.00
Your Output:
x = -1.00
5. Accepted
6. Accepted
7. Accepted
8. Accepted
9. Accepted
10. Accepted
Hello, I have seen your code. Your code has extra spaces when output. You look closely
Thank you, let me review the code
Please give me a stupid comment, so give me a link to solve the step pt 2 I'm a bit confused by google :v
:)) this must be remembered.
grandchild 8 I haven't learned yet, uncle :<
Then do another article or go online to learn more about it.
I thought in the manual you said you don't have to check your input, but why are there so many inputs. Always play a=b=0 :v
If the topic says conditions, you don't need to check. If you don't say it, you need to check it.
The topic is a bit confusing :v is already a degree equation 2 then a is always different 0 and the degree equation 2 There is only no solution or solution, but no infinite solutions
No. Must test every case. Have you seen the casio machine it requires another 0 hem?
I have the correct code but I get the error
1. Accepted
2. Accepted
3. Accepted
4. Accepted
5. Accepted
Runtime Error (NZEC)
Exception in thread “main” java.lang.ArithmeticException: divide by zero at Main.main(Main.java:17)
Can you translate the error into what is the core?.
Runtime error 200 at $000000000040029F $000000000040029F $000000000040018F
What's wrong with admin? :v
– If a # 0:
– – Calculate delta = b^2 – 4ac;
– – If delta PT has no solution
– – If delete = 0 => x = -b/(2a)
– – If delete > 0 //// >>>>> The teacher's explanation is wrong “delta nor =))
1. Accepted
2. Accepted
3. Accepted
4. Accepted
5. Accepted
6. Accepted
Rutime Error (SIGFPE)
I don't understand how to handle this error message
I have successfully fixed it
bro, when I code with x, the system outputs an output without x, and when I code output without x, the system outputs an output with x.. hope you can help me.
Test Input:
0 2 1
Test Output:
x = -0.50
Your Output:
-0.50
Test Input:
1 3 2
Test Output:
-2.00 -1.00
Your Output:
x = -2.00 y = -1.00
Do you have to see where your code is wrong?.
Can you tell me what -nan and -inf are?
Is no result. usually division by number 0 or the math is not reasonable.
please let me know test 10 is the case where j v is true 9 test r still 1 test 10 T^T
Please see the difference between Test output and your output.
it doesn't show test inp vs test out
Ah, this test, b, c are real numbers so you have the wrong data type.
tks ad
let me ask if i run to the line it says Runtime Error (SIGFPE) What does that mean
There was an error while running. (VD divided by 0)
still wrong
Please see the difference between Test output and Your output in the wrong tests.
why is the output not showing anything at the wrong time
6. Wrong Answer
Test Input:
0 0 0
Test Output:
VSN
Your Output:
Because your code prints null or doesn't
Honey, Please tell me what is this error?
“main.cpp: In function ‘int main()’: main.cpp:21:37: error: ‘sqrt’ was not declared in this scope printf(“%.2f%.2f”,(-b-sqrt(delta))/(2*a),(-b+sqrt(delta))/(2*a)); ^”
I don't have a library to use the sqrt command.
4. Wrong Answer
Test Input:
2 4 2
Test Output:
x = -1.00
Your Output:
-1.00
oh admin, why sometimes it says to print out x= -1.00, then sometimes it tells me to print it out -1.00 stop it
** I mean why sometimes print x and sometimes print without x
This is what the topic asks for.
but the moment I printed x, then it says not to print x
Please read the title carefully.
Brother to brother asked, why when i see your solution, then why -c/b?
I'm wondering where, -c/b what is your solution? ?
Re-learn how to solve step PT 2 Please. 😛
oh :), so if a=0 then deduce x= -c/b, isn't that right, admin?
please tell me test error 10: Runtime Error (NZEC)
Runtime error 106 at $00000000004001EB $00000000004001EB $000000000040018F
It's an error code.
HomeExerciseIf elseExerciseEquation 2
Quadratic EquationsBy nguyenvanquan7826 If else exercise 41 Comments Code Scoreboard
NOT IN HUE, MISSING than output. Read the instructions and code samples do post here if you're wrong or not know how to do
Threads: Let programmers program the quadratic equation 2: ax^{2} + bx + c = 0 with a, b, c typing.
Input: A line of 3 numbers separated by spaces.
Output: Print out the case.
1/ “VSN” – If the equation has infinitely many solutions
2/ “VN” – If the equation has no solution
3/ “x = 2.00” – If the equation has a solution (experience 2).
4/ If equation 2 experience, in 2 That experience in one line and separated by spaces. Little experience in front, large experience in the following.
The experience is rounded to 2 decimal.
For example:
input:
1 -2 1
output:
x = 1.00
#include
#include
int main ()
{
float a, b, c, dental;
float x, x1, x2;
scanf(“%f%f%f”, &a, &b, &c);
if(a==0){
if(b==0 && c!=0)
printf (“VN”);
if(b==0 && c==0){
printf (“VSN”);
}
else {
x=(float)-c/b;
printf (“%.2f”, x);
}
}
else{
denta=b*b-4*a*c;
if (dental<0){
printf ("VN");
}
else if(dental==0){
x=(float)-b/(2*a);
printf ("%.2f", x);
}
else {
x1=(float)(-b-sqrt(dental))/(2*a);
x2=(float)(-b+sqrt(dental))/(2*a);
printf ("%.2f %.2f", x1, x2);
}
}
}
1
#include
2
#include
3
int main ()
4
{
5
float a, b, c, dental;
6
float x, x1, x2;
7
scanf(“%f%f%f”, &a, &b, &c);
8
if(a==0){
9
if(b==0 && c!=0){
10
printf (“VN”);
11
}
12
else if(b==0 && c==0){
13
printf (“VSN”);
14
}
15
else {
16
x=(float)-c/b;
17
printf (“%.2f”, x);
18
}
19
}
20
else{
21
denta=b*b-4*a*c;
22
if (dental<0){
23
printf ("VN");
24
}
25
else if(dental==0){
26
x=(float)-b/(2*a);
27
printf ("%.2f", x);
28
}
29
else {
30
x1=(float)(-b-sqrt(dental))/(2*a);
31
x2=(float)(-b+sqrt(dental))/(2*a);
32
printf ("%.2f %.2f", x1, x2);
33
}
34
}
35
}
Submit View the system's solution
1. Wrong Answer
Test Input:
1 2 1
Test Output:
x = -1.00
Your Output:
-1.00
2. Accepted
3. Accepted
4. Wrong Answer
Test Input:
2 4 2
Test Output:
x = -1.00
Your Output:
-1.00
5. Accepted
6. Accepted
7. Accepted
8. Wrong Answer
Test Input:
0 2 1
Test Output:
x = -0.50
Your Output:
-0.50
9. Wrong Answer
Test Input:
0 2 -3
Test Output:
x = 1.50
Your Output:
1.50
10. Accepted
I'm wondering if the system is wrong or not
Please review the topic. See the difference between test output and your output.
#include
#include
#include
int main()
{
float a,b,c;
float x,x1,x2;
float d;
printf(“GIA PHUONG TRINH BAC 2 ax^2 + bx + c = 0n”);
printf(“Click here, b, cn”);
scanf(“&f&f&f”,&a,&b,&c);
if (a = 0)
{
printf(“\nPrinciple has unique experience: x = %f”,x = -c/b);
}
else
{
d = pow(b,2)-4*a*c;
if (d < 0)
{
printf("Phuong trinh vo nghiem");
}
else
{
x1 = (b-sqrt(d))/(2*a);
x2 = (-b-sqrt(d))/(2*a);
printf("Phuong trinh co 2 nghiem phan biet\n");
printf("x1 = %f",x1);
printf("x2 = %f",x2);
}
}
getch();
}
I have tried many ways but still don't understand why my if statement is not working, it dances all the time
Because you wrote it wrong. if (a = 0) or if (a == 0) ?
How many times do you need to go out to use debugging when scanf uses the wrong type?, mate v
6. Wrong Answer
Test Input:
0 0 0
Test Output:
VSN
Your Output:
VSN-in -in
7. Wrong Answer
Test Input:
0 0 1
Test Output:
VN
Your Output:
VN-in -in
8. Wrong Answer
Test Input:
0 2 1
Test Output:
x = -0.50
Your Output:
-0.50-inf -nan
9. Wrong Answer
Test Input:
0 2 -3
Test Output:
x = 1.50
Your Output:
1.50-inf -nan
what is this error?
you miscalculated.
huhu, I don't know where I got it 6/10, fix it bro
#include
#include
int main()
{
float a,b,c,x,x1,x2,delta;
scanf(“%f%f%f”,&a,&b,&c);
if (a==0)
{if(b==0&&c!=0){
printf(“VN”);
}
else if(b==0&&c==0)
{printf(“VSN”);
}
else {x=-c/b;
printf(“x=%.2f”,x);
}
}
else {
delta=b*b-4*a*c;
if(delta<0)
{printf("VN");
}
else if(delta==0) {
x=-b/(2*a);
printf("x=%.2f",x);
}
else
{ x1=(-b-sqrt(delta) )/(2*a),x2=(-b+sqrt(delta) )/(2*a);
printf("%.2f %.2f",x1,x2);
}
}
return 0;
}
You see where your output and test ouput are different to adjust.
Can anyone help me calculate the base?, I'm new so I don't know
you can use the square root function 2 sqrt(a) math.h library
or in general Square root n of a =a^1/n=pow(a,1/n)
There are a,b,c,t:integer;
begin
readln(a,b,c);
t:=(b*b)-(4*a*c);
if (t0) then writeln((-b-t)/(2*a):0:2,’ ‘,(-b+t)/(2*a):0:2)
else writeln(‘x = ‘,(-b)/(2*a):0:2);
end;
end.
I don't know where I went wrong to come to text 5 there know to
You double-check. see your output and the output of the program.
why is my submission running all the time,no matter how many times i refresh.
Please try again.
1. Accepted
2. Wrong Answer
Test Input:
1 3 2
Test Output:
-2.00 -1.00
Your Output:
-3.50 -2.50
3. Accepted
4. Accepted
5. Wrong Answer
Test Input:
2 6 4
Test Output:
-2.00 -1.00
Your Output:
-6.50 -5.50
6. Accepted
7. Accepted
8. Accepted
9. Accepted
10. Wrong Answer
Test Input:
1.5 5 2
Test Output:
-2.87 -0.46
Your Output:
-6.20 -3.80
there's nothing wrong with that
is it wrong here?:
is Input:
1.5 5 2
Test Output:
-2.87 -0.46
Your Output:
-6.20 -3.80