코드비교

Old VersionNew Version
1import java.util.Scanner; 1import java.util.*;
2class side { 2public class Main {
3static double get(double x1, double y1,double x2,double y2) { 3public static void main(String args[]) {
4return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); 4Scanner sc = new Scanner(System.in);
   5double a1,a2,a3, b1, b2, b3;
   6double s1, s2, s3, s, area;
   7a1 = sc.nextDouble();
   8b1 = sc.nextDouble();
   9a2 = sc.nextDouble();
   10b2 = sc.nextDouble();
   11a3 = sc.nextDouble();
   12b3 = sc.nextDouble();
   13s1 = Math.sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2));
   14s2 = Math.sqrt((a2 - a3) * (a2 - a3) + (b2 - b3) * (b2 - b3));
   15s3 = Math.sqrt((a3 - a1) * (a3 - a1) + (b3 - b1) * (b3 - b1));
   16s = (s1 + s2 + s3)/2;
   17area = Math.sqrt(s*(s - s1)*(s - s2)*(s - s3));
   18System.out.println(Math.floor(area*10)/10);
5} 19} 
6} 20} 
7public class Main {   
8public static void main(String[] args) {   
9Scanner sc = new Scanner(System.in);   
10double x1, x2, x3, y1, y2, y3;   
11double s1, s2, s3;   
12x1 = sc.nextDouble(); y1 = sc.nextDouble();   
13x2 = sc.nextDouble(); y2 = sc.nextDouble();   
14x3 = sc.nextDouble(); y3 = sc.nextDouble();   
15s1=side.get(x1,y1,x2,y2);   
16s2=side.get(x2,y2,x3,y3);   
17s3=side.get(x3,y3,x1,y1);   
18double s = (s1+s2+s3)/2;   
19System.out.println((int)(Math.sqrt(s*(s-s1)*(s-s2)*(s-s3))*10)/10.0);   
20}   
21}   
import java.util.Scanner;
class side {
static double get(double x1, double y1,double x2,double y2) {
return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double x1, x2, x3, y1, y2, y3;
double s1, s2, s3;
x1 = sc.nextDouble(); y1 = sc.nextDouble();
x2 = sc.nextDouble(); y2 = sc.nextDouble();
x3 = sc.nextDouble(); y3 = sc.nextDouble();
s1=side.get(x1,y1,x2,y2);
s2=side.get(x2,y2,x3,y3);
s3=side.get(x3,y3,x1,y1);
double s = (s1+s2+s3)/2;
System.out.println((int)(Math.sqrt(s*(s-s1)*(s-s2)*(s-s3))*10)/10.0);
}
}
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
double a1,a2,a3, b1, b2, b3;
double s1, s2, s3, s, area;
a1 = sc.nextDouble();
b1 = sc.nextDouble();
a2 = sc.nextDouble();
b2 = sc.nextDouble();
a3 = sc.nextDouble();
b3 = sc.nextDouble();
s1 = Math.sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2));
s2 = Math.sqrt((a2 - a3) * (a2 - a3) + (b2 - b3) * (b2 - b3));
s3 = Math.sqrt((a3 - a1) * (a3 - a1) + (b3 - b1) * (b3 - b1));
s = (s1 + s2 + s3)/2;
area = Math.sqrt(s*(s - s1)*(s - s2)*(s - s3));
System.out.println(Math.floor(area*10)/10);
}
}