0 like 1 dislike
15k views

Write a program to find roots of a quadratic equation

quadratic equation is a second order equation having a single variable. Any quadratic equation can be represented as where a, b and c are constants ( a can't be 0) and x is unknown variable. 

寫一個找二次方程的求根程式

For Example

 is a quadratic equation where a, b and c are 2, 5 and 3 respectively.

To calculate the roots of quadratic equation we can use below formula. There are two solutions of a quadratic equation.

使用下列公式:

x = (-b + sqrt(D))/(2*a)
x = (-b - sqrt(D))/(2*a)

where, D = (b*b-4*a*c) is Discriminant (判別式), which differentiate the nature of the roots of quadratic equation.

For the complex result (複數根):

realPart = -b/(2*a);
imaginaryPart =sqrt(-D)/(2*a);

Note: We have used sqrt() function to find square root which is in math.h library.

 

Example input 1:

1 2 1

Example output 1:

Roots of 1.00x^2 + 2.00x + 1.00 = 0 are real and same
x1 = x2 = -1.00

 

Example input 2:

1 -3 2

Example output 2:

Roots of 1.00x^2 + -3.00x + 2.00 = 0 are real and different
x1 = 2.00
x2 = 1.00

 

Example input 3:

1 2 2

Example output 3:

Roots of 1.00x^2 + 2.00x + 2.00 = 0 are complex and different
x1 = -1.00+1.00i
x2 = -1.00-1.00i
[Exercise] Coding (C) - asked in Chapter 5: Selection Statements by (5.2k points)
ID: 28934 - Available when: 2017-10-26 18:00 - Due to: Unlimited

reopened by | 15k views
0 0
We will continue this question in few days
0 0
Everything is fixed. Enjoy your time with The Judge :)
0 0
ANNNNNNNNNNNNNNNNNNNNNNNNNNGRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
0 0
Your code has newline at the end sometime. You learned this lesson many times!
0 0
After i correct the newline in my code,there is still wrong output.However,I had run the program in Codeblocks.The output is still as well as the result. Seeking for help.
0 0
your output lack of 1 space at line 8 when print out "Roots of ...". Please be careful with all small details when working with online judge

56 Answers

0 like 0 dislike
Hidden content!
* * * *
*** * ** **** * *
int main()
{
* * * * * *** * a,b,c,D = 0,x1 = 0,x2 = 0,Real = 0,imaginary = 0;
*** * * * * *** ** * * * **** ** * **** ** * * * * ** *****

** ** ***** * * ***** ***** * * ** ** of %.2fx^2 + %.2fx +%.2f = 0 are",a,b,c);
**** * ** ** ** * *** = (b*b-4*a*c);
*** *** **** * * *** = (-b + sqrt(D))/(2*a);
* * *** * * ** * *** = (-b - sqrt(D))/(2*a);
** * * *** **** * (D < 0)
**** * * * ** **
* * ** ** ***** * *** **** * complex and * ** * ****
*** * ****** ** **** ** ** = ** * **** * ** * ** ** *** * * **
* * * * **** ** * * *** = ** ** * ** ******* * * * ***** **
* ** ** **** *** ***** *
*** * ** **** * * * (D > 0)
** ** ** * * ** * **
* *** ** * * **** * * * **** real and * * *** **
* *** ** * * * * *** **** ** * * = *** * * ****
* * * * * * *** ***** * ** = %.2f",x2);
* * ** * * * ** * **
* **** * * * * *** *** * * (D == 0)
* * * * ***** * ** *
* * * * ** ** * * **** * real and same\r\n");
*** * * * * * *** * * **** = x2 = %.2f",x1);
* ****** ** **
}
answered by (-214 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
* * ** * ** *
int main(void)
{
* * ** ** * ** **** * a,b,c,D = 0,x1 = 0,x2 = 0,Real = 0,imaginary = 0;
* * *** *** ** ***** * * * ** * * **** ** **

* * * * **** * ** * * ** *** * of %.2fx^2 + %.2fx +%.2f = 0 * * * ****** *
* ** * ** * *** = (b*b-4*a*c);
* * ** ** * * ** = (-b + sqrt(D))/(2*a);
* ** * **** ** ** * = (-b - sqrt(D))/(2*a);
* ******* *** ****** * ** = -b/(2*a);
*** * **** * * * ** * * = sqrt(-D)/(2*a);
* ** ** * * ** ** **** (D < 0)
** ** ***** **** * **
***** **** * * * **** ** complex and *** * ** *
* ** * * **** * ** * *** * * = * * * ** * *** * * * *
*** * *** * *** ***** *** * ** * * * = **** ** **** ****
*** * ** ** * * **
* * * *** * * *** * * (D > 0)
* * * * * * ** * * * *
* ** *** **** ******** ** * * real and * ** * * *** *
***** ********** *** * ** ** * * ** **** *** = ** ** ***
**** * ** **** * * * ** * ** = %.2f",x2);
* * * * * ****
* * * * * * *** ** (D == 0)
* * * * ***** *** *
****** **** * * **** * ****** real and same\r\n");
* * * * * ** * *** ** ** * = x2 = %.2f",x1);
*** * ** ** *******
}
answered by (-214 points)
0 0
prog.c: In function 'main':
prog.c:9:16: warning: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
     x1 = (-b + sqrt(D))/(2*a);
                ^~~~
prog.c:9:16: warning: incompatible implicit declaration of built-in function 'sqrt'
prog.c:9:16: note: include '<math.h>' or provide a declaration of 'sqrt'
0 like 0 dislike
Hidden content!
* *** * ** ** *** *
# ** ** * ** * * * **
int main()
{

** ** * * **** * * * * * ** ** * ** *
* * *** ** * ** * ** *** * %f * *** *** ** * * * * ** ** *
* **** **** * * * = (b*b-4*a*c);
***** ** *** *** * *** ** * = (-b + sqrt(D))/(2*a);
**** * * *** * * * ** * * = (-b - sqrt(D))/(2*a);
**** **** ** ***** * *** *** ***
* ** * * * * ******
* *** * ** ** * *** ** *** ** ** * * * **** = -b/(2*a);
** ***** ** * *** ****** * ** ** ** *** *** * * =sqrt(-D)/(2*a);
* *** ******* *** * * * * ** *** * * *** * * ***** ** * of %.2fx^2 + %.2fx + %.2f = 0 are complex and * * * **** ******
* * * ** **** * * * * * * **** * * * ** ** *** * * * = %.2f+%.2fi\n", realPart,imaginaryPart);
* *** ** ** * * * * ** * ****** ** * * ** ** = %.2f+%.2fi", * * * *
**** * *** *** * *** * *
*** * * ** * ** * * if(D == 0)
** ** * * * * *

* * **** ***** ***** * * * * * ****** **** * *** * *** ** of %.2fx^2 + %.2fx + %.2f = 0 are real and * ** * *** *
* ** * * ** * ***** * *** * * * ** ** ***** * ******* ** = x2 = %.2f", x1);
* ** * ***** * ** ** * *
*** * ***** * *
*** * **** * **
**** * * * ***** ** * * * * * * ** *** ** * * * * of %.2fx^2 + %.2fx + %.2f = 0 are real and * * * ** *
****** * * *** * ** * * **** *** * ** ** * ** ** = %.2f\n", x1);
* ** * *** * * * *** ** ** ** *** ****** ***** * * ** = %.2f", x2);
** * ** * * **
* * **** ** *** ***** 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
0 like 0 dislike
Hidden content!
* * ** **** * *
# **** * * ******
int main()
{

* ** * * * * * ** * * * ** * ***** ***
*** ** *** ** * ** ** * * ** ** %f * ** * ** * ** *** *
*** **** ** ***** = (b*b-4*a*c);
** * * * ******* = (-b + sqrt(D))/(2*a);
** * **** * *** = (-b - sqrt(D))/(2*a);
* * ** ** **** * * * *
**** ** * * * * ** ** **
** *** * *** * *** ** ** * * ** * * * * **** * = -b/(2*a);
*** ** * * * * * ** * * * * ** ***** ** ** *** * * * =sqrt(-D)/(2*a);
** * ** * * *** ** * * *** * * * * *** ** ** * ** of %.2fx^2 + %.2fx + %.2f = 0 are complex and ** * *** ** ***
** *** * ** *** *** * * ***** *** **** **** *** ***** = -%.2f+%.2fi\n", realPart,imaginaryPart);
** *** * * * ********* * ** * *** ***** * ** * ** ** = -%.2f+%.2fi", * ***** **
* ** ****** * ** *
* ** * * ** ** ** * ** *** if(D == 0)
* ** *** **** ** *

* **** *** * * **** ** **** ******* ** *** * ** *** ** * of %.2fx^2 + %.2fx + %.2f = 0 are real and ** ** ** * *
**** * * * * **** * **** ** ** ** * * ** = x2 = %.2f", x1);
* ** * * ** **** ***
* **** ***** ** * *
*** * * * * * ***
** ** * *** ** * * * *** * * **** * ****** * ******* * * of %.2fx^2 + %.2fx + %.2f = 0 are real and ** **** * ** *
** * * * ********** *** *** *** * ***** * * ** * * ** * * * = %.2f\n", x1);
* * *** * * * ** ******* ** * * * **** * ** * ** = %.2f", x2);
** * * ** ** ** *
** * * * ** * ** *** * * 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
**** * * * * * **** a, b, c, D, spD, x1, x2;
    
* ** ** *** ** * * *** ** * * %lf %lf", &a, &b ,&c)==3)
    {
* * **** *** *** * *** * ** * * **** **** - (4*a*c);
*** * * ** * * * * * * **** *** * * *
*** * *** * *** **** * * ** * *** * * ****
* ** ** ** * * * *** * * ** ** * ****
** * ** ** * * * ** *** ** * * ** *** ** ***** * *** *** ** * ** ***
** ** ** ** * *** * * * *** ** ** *** ******** *** * * * * ** *** ** (-b+spD)/(2*a);
**** ** * * * ** *** ** *** *** *** **** *** * *** * * * * * * *** * *** * (-b-spD)/(2*a);
* * ** ** **** ** *** ** * * * ** *** * ** * * * * ***** ******* * * (x1==x2){
** * *** * ** * ** ** * ** ** * ** * *** ** ***** ** ** * * ***** ** * * * ** * * * ** ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
* * * * * * ** *** * * * **** * ******** * * * **** * *
* ** ** * *** * ** ** ** * * * *** * * ** *** *** * ** *** ** {
** ** **** * **** ** ** ** *** ** ** ** * ** ** * * ** * * *** ***** ** ** *** * *** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and different\nx1 = %.2lf\nx2 = %.2lf",a,b,c,x1,x2);
* ** * * ***** ** * * * *** *** ** ** ** *** *** ***** * * ** ** ** *****
* ** * * * * ***** * * **** ** *** * * *
******* *** ** * ** * * * ** * * ** *** * * * * if(D==0)
* * * ***** * *** * * ** *** * **
* * * *** ** * ***** ** * * * ** * * *** ** * *** ** *** * ** ** (-b)/(2*a);
* ** * ** ** ** *** *** ***** **** ***** ** * **
* *** * * * * * **** **** * ***** ** * ************ **
* * * * * * * * ** * * ** ** ** * ** * * *** * ** * ** * * * * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
* ** *** **** * * *** * * * * *** **** * * **** *** * ** * * *
***** * ***** ** * * *** **** * *** * ** ********* * ** ** *
*** * * ** * *** * * * * ** *** ***** ** * ** * ** * * * * * ** ***
* * * **** * * ******* ** * * * * * * * *** * * * * ** ***
* * **** ***** ** **** * * * * * ** ** * ** * * ** ** * ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
**** ** * * ** * * * ** * * * *** * * * *** * * ** ****** ** * * ****** * *
* * * * * * ** ** * * **** * * * *** * *
***** * ***** ** ** ***** **** ** * ** * ** * if(D<0)
*** * * * * * ** * * * * **** **    
** * * ** * * ** * *** * **** * ** ** * *** * **** * ** ***** * (-b)/(2*a);
* * ** ** ** ** * * *** *** ** ** * * ** ***** ** * **** ** ** ** -x1;
* * * * * **** * * *** * * * **** ** ** * ** * ***** * * ** * * * ** *** ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are complex and different\nx1 = %.2lf+%.2lfi\nx2 = %.2lf%.2lfi",a,b,c,x1,x2,x1,x1);
* ** ** ***** ** ** *** **** * * * **
* ** * **** *** * * **
    
* ** * **** *** * * * *** ** * ****** *
* * * * ** * * ** * * 0;
}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdlib.h>
#include<math.h>

int main(void)
{
* *** *** * * **** ** a, b, c, D, spD, x1, x2;
    
* **** ** ** * * * ****** * ** %lf %lf", &a, &b ,&c)==3)
    {
* ** * ** * * * **** * *** ** *** - (4*a*c);
* **** * * **** * * * **** ** ** * ** ** **
** ** * * **** ** * ***** * * * * * ** *** *
** * * * ***** * ** ** ** * * ** * **
***** *** **** * *** * * * ** *** * *** * * ************ * ** * * **
*** ****** ** * * * ** *** * * * ** * * * ** ** ****** ******** * * *** * * (-b+spD)/(2*a);
* * ** * ** ** **** **** * * *** ** * ** ****** * * *** ** * * * (-b-spD)/(2*a);
* * ** * * ** **** *** ** **** * ** ** * *** **** * * * (x1==x2){
*** *** *** * * *** ** * * ** * * * ** * ** * **** * * ***** *** ** * ****** * * *** **** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
* *** ** * ** **** * * ** ** * * * *** ** ** * * * * ** ** * *
** * * * * ** * ***** **** ** * ** * * ** *** * * * **** ** * * {
***** * * ** * * * * ***** *** ** * ** * * * **** * * ** * ** * ****** * ******* ** *** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and different\nx1 = %.2lf\nx2 = %.2lf",a,b,c,x1,x2);
* * **** * * ** * ***** *** *** ** ** ** * *** ** ******
* ** * ** * * * * * * *** *** **** **
* * ******* *** *** * **** * ** * ** *** * if(D==0)
**** **** ** * ***** ** ******* ***** **
**** * ** ** * * ** ** ** **** *** ** ** * ** ** ** ***** ** **** * * ** * (-b)/(2*a);
* * * * * * ** * ** * * ****** * * ** * * ** * * **
* * * * * * ******* * * *** * *** *** * * * ** *** * ** **
** * ** *** * ** * ** * ** * ** * ************ * ** ******* ** *** * ** * ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
* * ** ** ** * ****** * ** ** * *** ** * * *** * * ***** * *** * **
* **** ******** ** ** *** * *** *** * ** ** * * * ** ** * ***
** * ** * *** * * ****** * *** **** ** ** * *** * * ** * * * * * *
* ***** * ** ***** ****** *** *** ** * ** ** * * * * * ** ****** * *
* *** ****** **** ** ***** ** **** ******* * * **** * * ****** ** ** ** ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
* ** ******** ** ** ** * * * * *** * **** * * * *** **** ** * **** * * * *
*** ** * ** *** ** * ** * ** * * *
* *** *** * ** ** * * * ***** * * ** * **** * * if(D<0)
* * * * ** * ***** * * * ** ******    
*** ***** ** * * ** * * * *** *** *** **** ** * * * * *** * ** * (-b)/(2*a);
* * *** *** *** *** *** * * ** * * *** * * ** * * ** ** -x1;
** * * * ** * *** * ** * * ** ** ****** **** **** ** ** * **** *** of %.2lfx^2 + %.2lfx + %.2lf = 0 are complex and different\nx1 = %.2lf+%.2lfi\nx2 = %.2lf%.2lfi",a,b,c,x1,x2,x1,x1);
** * ******* * * * * * ***** * * * * *
* *** * ** *** ** ****
    
* * * *** * * * ***** **** ** ** *
* * ** * * ** *** ** * ** 0;
}
answered by (-249 points)
0 0
prog.c: In function 'main':
prog.c:8:11: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     while(scanf("%lf %lf %lf", &a, &b ,&c)==3)
           ^~~~~
prog.c:8:11: warning: incompatible implicit declaration of built-in function 'scanf'
prog.c:8:11: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:18:17: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
                 printf("Roots of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
                 ^~~~~~
prog.c:18:17: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:18:17: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:21:17: warning: incompatible implicit declaration of built-in function 'printf'
                 printf("Roots of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and different\nx1 = %.2lf\nx2 = %.2lf",a,b,c,x1,x2);
                 ^~~~~~
prog.c:21:17: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:29:13: warning: incompatible implicit declaration of built-in function 'printf'
             printf("Roots of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
             ^~~~~~
prog.c:29:13: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:34:13: warning: incompatible implicit declaration of built-in function 'printf'
             printf("Roots of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf",a,b,c,x1);
             ^~~~~~
prog.c:34:13: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:41:13: warning: incompatible implicit declaration of built-in function 'printf'
             printf("Roots of %.2lfx^2 + %.2lfx + %.2lf = 0 are complex and different\nx1 = %.2lf+%.2lfi\nx2 = %.2lf%.2lfi",a,b,c,x1,x2,x1,x1);
             ^~~~~~
prog.c:41:13: note: include '<stdio.h>' or provide a declaration of 'printf'
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
* * * ***** * * ** a, b, c, D, spD, x1, x2;
    
* * * ** * * * * ** * ** * *** %lf %lf", &a, &b ,&c)==3)
    {
*** * * * * ** ******* * * * **** ** ** **** - (4*a*c);
*** * ** ** ** * * ** *** ** *** ** *** **
*** ** ** * * ****** * * *** * * * *** *** * * * * *
** * * * ****** ** *** ** * *** **** *
* * ** *** * ** *** ** ** ** * * **** * ** *** * ** * * *** ** ****** *
* * * ** ** *** * * * * ** ** * * * * * * * *** (-b+spD)/(2*a);
**** * ** *** * *** * **** *** * *** * * * ****** **** * *** * * (-b-spD)/(2*a);
* **** *** * ** **** * * ** *** ** ** ***** * * * * ** (x1==x2){
** * * * ** * * * ** ****** * * ** ** * * * ** * **** * * ** * ** ** * * * * ** * ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf\n",a,b,c,x1);
*** * *** * * ** ** * ** ** * ****** *** **** ***** * ** ** * *** * ****
* * ** * * * **** * * * * *** ** * *** * * * *** ***** * * * {
* ****** *** * ** *** * ** ** * * * ** * * ** ** *** ** ** * * * *** *** * ** *** ** ** * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and different\nx1 = %.2lf\nx2 = %.2lf\n",a,b,c,x1,x2);
*** * * ** * *** * **** *** *** ** ** ** ***** * ** * ****
* * **** * **** ** * * * ** ** *** **
** * ** ** *** * ** *** ******* ** * * * ** * if(D==0)
*** * *** ** * * * * ** * ** *
****** * * * **** ***** *** ** *** *** *** *** *** * * ** * ****** (-b)/(2*a);
** * ** ******* **** * * **** * * *** * ** * ** * ** * ** ****
* ** *** * * * * * * ***** ****** * * ** * * ** * * * ** *
* ** * **** *** ** * * ** ***** * * * * * * * ** * * * * ** ** * ** * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf\n",a,b,c,x1);
* **** * ** ** **** ***** ** ** *** * ** * ** * * * * *** ** * * **
*** ** * **** ** * ** ** *** * ** * ** * * * * * * * * ** **
** * ******** *** **** * ***** * * ***** *** * * * **** * ** * *
*** *** * **** *** * *** ***** * * * * ** ** *** * * ** * ** * *** * * *** ***
**** * * * **** *** *** ** * **** * * **** ** ** * * * * * * * * ** * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = %.2lf\n",a,b,c,x1);
** ***** ***** * * ** * * ** ** ** ** * * **** * *** * * ***
* ** * * * * * * * * * ***** * * *** * * **
******* ***** ** * * ** *** * ** * ** if(D<0)
* * **** * * * *** * * * ** **    
************ *** * * ** *** * * * * * * * * * ** * *** ** (-b)/(2*a);
** * * * **** * **** ** * **** ** * ** ** *** ** * ** * -x1;
******* * *** * * **** * *** * *** ** * ****** ** * ** * **** ** **** ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are complex and different\nx1 = %.2lf+%.2lfi\nx2 = %.2lf%.2lfi",a,b,c,x1,x2,x1,x1);
* * *** * * ** ** **** ** * * ** ***** ** ** *
* * ** * * * * * * ** *
    
** ** ** * * * **** * * ** * ***** *
* *** * ** ** ** *** 0;
}
answered by (-249 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
*** ***** ** *
**** * ** ** * **
* ** * ****** * **
int *** **
**** **** ** * * ** * * *** a, b, c, D, spD, x1, x2;
** * ***** *** * *** ****
* *** ** *** * * * ** * ** %lf * * *** ** *** ** &b * ** **
* *   {
******* * * *** * * * ** *** ** **** * * * * *** * * - (4*a*c);
* *** ******* * **** * * ***** ** * * *** *
* *       * * * ***
* * *       {
*** *** * * ** * * ***** *** **** * * * * ***   * ** **
* * ** * ** * ******* * ** * ** * * * ** * **   x1= **** ***
** ** * **** * ** ***** ** * *** * * **** ** ** **   x2= ** *** ***
* * * * * * ****** **** **** *** * * ** ** ** * * *** **   if (x1==x2){
** *** * ** * * * * ** * **** * * ** ** * * *       ** ** ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = * * *** *
* *** ** * *** * ** ** * * * * * * **** * ****** * ***** * **** ****
* ** ** * * * ** * ***** * * * * * * ****   else {
* * ** ** * * * * * ** * * * * * * * * ** ***** * ****   *** * * * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and ** * = %.2lf\nx2 = * * ** * ****** ** *
** ** * * ** * ** ** ** * * ** ***** ** * * ** * * }
* * ** ** ** * *** * * * * * ***** ***
* ** ** * ** * * * ****** ** ** ** * * * *** ** **** if(D==0)
** **** * * * * *   {
* **** ** * ** * ** * * *** ** * ** ** ****** * ****** ** ** * * *** * * * *
** * ** *** *** ** ** *** * ** *** * * **** * * ** ****** *** ****
* **   *** * *       {
* ** ** * *** ** *** * * * * * * * *** * ****** * * ** ******* * * * *** ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = ** * * ***** ***
*** * * *** ** ** * * ** ** ** **** * ** *** ***** * * * **
********** * * * ** * * *** * *** * *** *** * * ** * * ** **
* * * * * * * * * * *** **** ** * * * * *** *** * * * *
** *           {
** *** * ****** * * **** ** * ** *** * *** ** * *** * * *** * **** ** * of %.2lfx^2 + %.2lfx + %.2lf = 0 are real and same\nx1 = x2 = ** * ** ******** *
******** * ** * * * ** * * * * * *** * **** *** * *** * ** ** * * **
** * **** ******* * * * * * * ** * ** ** * * * ***
** *** * *** ** * ** * * * * * * * * **
* * *       * * *  
            x1= ** ** *
* *** *     * ** * * ** * ** x2= -x1;
* * * ** ***** ** * ** * ** ** ****** * ** **** * * * * *** ** **** ** * ** of %.2lfx^2 + %.2lfx + %.2lf = 0 are complex and *** * ** = * * * ** ** = * * ** * * * **** *
** ******** ** ** *** ** * * *** * * ** ** **
** * * *** * ** *
**** * * * **** ***
*** ** *** * * * ** * * * * * *** ** *
* * * * *** * ** *** * ** 0;
}
answered by (-249 points)
0 0
/tmp/ccvUqbC2.o: In function `main':
prog.c:(.text+0x6e): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
* *** * * ****
**** ***** *** ** *
int main(){
* ** * ** * * ** * **** **** a,b,c;
** * * ** ** * * ** * D;
** ** ** * ** ** * * ***** * ** %lf * * ****** **** * * * *
* ** ** **** *** - 4*a*c ;

* *** *** * ** * * ** **** ** * ** ** of %.2fx^2 + %.2fx + %.2f = 0 * ** ** *

** ******** ****** * * * *** ****
* ** * *** ***** ** * * ** *** ** ** * * **** complex and ** * * * ***** *
* ** ** * ** *** * ** * ** *** * *** ** * * = ****** ** * ** (-b) / (2*a) ), sqrt(-D) / (2*a) );
** * ****** * * * ** ** * ***** * *** ** * * * *** * = *** ******* (-b) / (2*a) ), sqrt(-D) / (2*a) );
* * * **** *
**** * **** * ** * * if(D==0){
* * * * ***** ** * *** * * **** * *** * ** * ** * *** ** real and same\n");
* * ** ** ** ** ** **** * * ** *** * ** ***** ** = x2 = %.2f",( (-b) / (2*a) ) );
* *** * * * *** ** ** * *
* * ** *** * *** * * * *
** * * * *** * ***** ***** * ** * * * ***** * * ** real and * ***** ** *
***** **** ** * * * **** * ******** ** ** **** ** ** ** = %.2f\n",( ((-b) + sqrt(D)) / (2*a) ) );
* * * * * * **** ***** ** ** *** * **** * * ***** = %.2f", ( ((-b) - sqrt(D)) / (2*a) ) );
* ** *** *** ** * *

* * * * * ** ** ***** 0;
}
answered by (-116 points)
0 0
/tmp/cc8OPUJA.o: In function `main':
prog.c:(.text+0x51): undefined reference to `pow'
prog.c:(.text+0xdd): undefined reference to `sqrt'
prog.c:(.text+0x13f): undefined reference to `sqrt'
prog.c:(.text+0x213): undefined reference to `sqrt'
prog.c:(.text+0x26a): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
0 0
/tmp/ccLeUfQ5.o: In function `main':
prog.c:(.text+0x51): undefined reference to `pow'
prog.c:(.text+0xdd): undefined reference to `sqrt'
prog.c:(.text+0x13f): undefined reference to `sqrt'
prog.c:(.text+0x213): undefined reference to `sqrt'
prog.c:(.text+0x26a): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include * * * * ****
#include <math.h>
int main()
{
* *** * * * * * * *** a,b,c,x,y,d;
* **** * ** * * * **** * * **** %f **** * * * * ** *** **
*** *** * ** ****** ** **
**** * ************* *** * * * ** *
** ** ***** * ** * * *** ***
* * ** *** *** (d>0){
** ** ** * * * ***** of %.2fx^2 + %.2fx + %.2f = 0 are real and * ** ** * *** *
* * ** *** ** * * ** ** * = %.2f\nx2 = %.2f",x,y);
* * * ** ** ** * * * *
* *** * **** * *** * if (d==0){
** ** * *** *** * **** * * * * * of %.2fx^2 + %.2fx + %.2f = 0 are real and ** * ** *
* * * *** ** ** ** * **** ** = x2 = %.2f",x);
* * *** ** * **** * ***
** * ** *** * *** ** * **
* ** * * * * * ** ** * * * **
*** **** * *** ** * * * * *** *** of %.2fx^2 + %.2fx + %.2f = 0 are complex and * * * **
** * ** ** *** ** * * *** ** * ** *** *
*** * * * * * ** * * *** ** * = ** *** * ** *
* **** *** * ** * * * * *** * * = * ** ** ** * ** *
** * * * * ** ** *

***** ** * * * ** 0;
}
answered by (54 points)
1 0
/tmp/ccheVQNV.o: In function `main':
prog.c:(.text+0x87): undefined reference to `sqrt'
prog.c:(.text+0xd5): undefined reference to `sqrt'
prog.c:(.text+0x21f): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
0 0
/tmp/ccJPGNPl.o: In function `main':
prog.c:(.text+0x87): undefined reference to `sqrt'
prog.c:(.text+0xd5): undefined reference to `sqrt'
prog.c:(.text+0x21f): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.241.33
©2016-2025

No related questions found

12,783 questions
183,442 answers
172,219 comments
4,824 users