PAT提示返回非零,请问如何解决?
北风吹冷 2014-09-14 09:01:14 import java.text.DecimalFormat;
import java.util.Scanner;
public class IO_11 {
public static void main(String[]args)
{
String result="";
int x1;
int y1;
int x2;
int y2;
int x3;
int y3;
Scanner input=new Scanner(System.in);
x1=input.nextInt();
y1=input.nextInt();
x2=input.nextInt();
y2=input.nextInt();
x3=input.nextInt();
y3=input.nextInt();
input.close();
double edge1=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double edge2=Math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
double edge3=Math.sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
double p=(edge1+edge2+edge3)/2;
DecimalFormat dFormat= new DecimalFormat("#.00");
if((edge1+edge2<=edge3)||(edge1+edge3<=edge2)||
(edge2+edge3<=edge1)||
(Math.abs(edge1-edge2)>=edge3)||
(Math.abs(edge1-edge3)>=edge2)||
(Math.abs(edge2-edge3)>=edge1))
result="Impossible";
else
result="L = "+dFormat.format(2*p)+", "+"A = "+dFormat.format(Math.sqrt(p*(p-edge1)*(p-edge2)*(p-edge3)));
System.out.println(result);
}
}