Home > Back-end >  For help
For help

Time:11-18

A given plane coordinates of any three points (x
? 1
?? , y
? 1
?? ), (x
? 2
?? , y
? 2
?? ), (x
? 3
?? , y
? 3
?? ), check whether they constitute a triangle,

Input format:
Input sequence is given in a line of six? [100100] within the scope of digital, namely the coordinates of three points
X
? 1
?? , y
? 1
?? , x
? 2
?? , y
? 2
?? , x
? 3
?? , y
? 3
?? ,

The output format:
If the three points can't form a triangle, the output in one line "Impossible". If you can, then output in one line of the triangle pupil, format is "L=c, A=area", the output to 2 decimal places,

Input the sample 1:
4 5 6 7 8 9
The output sample 1:
L=10.13, 3.00
A=





I




# include "stdio.h"
# include "math. H"
Int main ()
{
Float a, b, c, d, e, f, g, h, I, j, k;
Double x=2;
The scanf (" % f % f % f % f % f % f ", & amp; A, & amp; B, & amp; C., & amp; D, & amp; E, & amp; F);

(g)=SQRT ((double) (pow (double) (a - c), x) + pow ((double) (b, d), x)));
(h=SQRT ((double) (pow (double) (c - e), x) + pow ((double) - f (d), x)));
(I=SQRT ((double) (pow (double) (a - e), x) + pow ((double) - f (b), x)));
If (g + h> I& & G - h H& & G - i G& & H - i{j=g + h + I;
K=j/2;
K=SQRT ((double) - g (k) (k * * * (k - I) - h (k)));
}
The else {
Printf (" impossible \ n ");
return 0;
}
Printf (" L=% 2 f, A=%. 2 f \ n ", j, k);

}


Why the pta submitted shows the answer wrong?

CodePudding user response:

Changes are as follows:
 int main () 
{
Float a, b, c, d, e, f, g, h, I, j, k;
Double x=2;
The scanf (" % f % f % f % f % f % f ", & amp; A, & amp; B, & amp; C., & amp; D, & amp; E, & amp; F);

(g)=SQRT ((double) (pow (double) (a - c), x) + pow ((double) (b, d), x)));
(h=SQRT ((double) (pow (double) (c - e), x) + pow ((double) - f (d), x)));
(I=SQRT ((double) (pow (double) (a - e), x) + pow ((double) - f (b), x)));
If (g + h> I& & G - h H& & G - i G& & H - i{j=g + h + I;
K=j/2;
K=SQRT ((double) - g (k) (k * * * (k - I) - h (k)));
Printf (" L=% 2 f, A=%. 2 f \ n ", j, k);//print should be placed here
}
The else {
Printf (" impossible \ n ");
//return 0; The redundant
}
return 0;
}

CodePudding user response:

# include "stdio.h"
# include "math. H"
Int main ()
{
Float a, b, c, d, e, f, g, h, I, j, k;
Double x=2;
The scanf (" % f % f % f % f % f % f ", & amp; A, & amp; B, & amp; C., & amp; D, & amp; E, & amp; F);

(g)=SQRT ((double) (pow (double) (a - c), x) + pow ((double) (b, d), x)));
(h=SQRT ((double) (pow (double) (c - e), x) + pow ((double) - f (d), x)));
(I=SQRT ((double) (pow (double) (a - e), x) + pow ((double) - f (b), x)));
If (g + h> I& & G - h H& & G - i G& & H - i{j=g + h + I;
K=j/2;
K=SQRT ((double) - g (k) (k * * * (k - I) - h (k)));
}
The else {
Printf (" impossible \ n ");
return 0;
}
Printf (" L=% 2 f, A=%. 2 f \ n ", j, k);

}
Error
It should be
# include "stdio.h"
# include "math. H"
Int main ()
{
Float a, b, c, d, e, f, g, h, I, j, k;
Double x=2;
The scanf (" % f % f % f % f % f % f ", & amp; A, & amp; B, & amp; C., & amp; D, & amp; E, & amp; F);

(g)=SQRT ((double) (pow (double) (a - c), x) + pow ((double) (b, d), x)));
(h=SQRT ((double) (pow (double) (c - e), x) + pow ((double) - f (d), x)));
(I=SQRT ((double) (pow (double) (a - e), x) + pow ((double) - f (b), x)));
If (g + h> I& & G - h H& & G - i G& & H - i{j=g + h + I;
K=j/2;
K=SQRT ((double) - g (k) (k * * * (k - I) - h (k)));
Printf (" L=% 2 f, A=%. 2 f \ n ", j, k);
}
The else {
Printf (" impossible \ n ");

}
return 0;
}

CodePudding user response:

If (a& & B | | c) operation order is from right to left, and you write is calculated from left to right, it will surely go wrong (here's a, b, c are all expressions)
  • Related