import t.Point;import java.util.Scanner;import th.*;public class test3 { class Point{ private double x,y; public Point(){
import t.Point;import java.util.Scanner;import th.*;public class test3 { class Point{ private double x,y; public Point(){ x=0;y=0; } public Point(double x,double y){ this.x=x;this.y=y; } public double getX(){ return x; } public double getY(){ return y; } public class Triangle{ private Point p1,p2,p3; public Triangle(){ p1=new Point(); p2=new Point(); p3=new Point(); } public Triangle(double x1,double y1,double x2,double y2,double x3,double y3){ p1=new Point(x1,y1); p2=new Point(x2,y2); p3=new Point(x3,y3); } public double getArea(){ double x1= tX(),y1= tY(),x2= tX(),y2= tY(),x3= tX(),y3= tY(); double s1=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); double s2=Math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); double s3=Math.sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)); double p=(s1+s2+s3)/2; double a=Math.sqrt(p*(p-s1)*(p-s2)*(p-s3)); return a; } } /** * @param argsstaticstatic */ public void main(String[] args) { // TODO 自动生成的方法存根Triangle A=new Triangle(3,4,2,3,4,4); tArea();} }}
展开
全部