Advertisement
teddy-popova

zadacha za triugulnik

Oct 23rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. import javax.lang.model.util.ElementScanner6;
  4.  
  5. class Main {
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8.  
  9. double x1 = Double.parseDouble(scan.nextLine());
  10. double y1 = Double.parseDouble(scan.nextLine());
  11. double x2 = Double.parseDouble(scan.nextLine());
  12. double y2 = Double.parseDouble(scan.nextLine());
  13. double x3 = Double.parseDouble(scan.nextLine());
  14. double y3 = Double.parseDouble(scan.nextLine());
  15.  
  16. if (x1*(y2-y3)+ x2*(y3-y1) + x3*(y1 - y2) == 0){
  17. System.out.println("Three points on one line!");
  18. }else {
  19.  
  20. double a = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  21. double b = Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
  22. double c = Math.sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
  23.  
  24. double p = (a+b+c) /2;
  25.  
  26. double s = Math.sqrt(p*(p-a)*(p-b)*(p-c));
  27. System.out.printf("s = %2f", s);
  28.  
  29. }
  30.  
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement