코드비교

Old VersionNew Version
1import java.util.Scanner; 1import java.util.Scanner; 
2public class Main { 2public class Main { 
3public static void main(String[] args) { 3public static void main(String[] args) { 
4Scanner input = new Scanner(System.in); 4Scanner scan = new Scanner(System.in);
5double x1 = input.nextDouble(); 5double x1 = scan.nextDouble();
6double y1 = input.nextDouble(); 6double y1 = scan.nextDouble();
7double x2 = input.nextDouble(); 7double x2 = scan.nextDouble();
8double y2 = input.nextDouble(); 8double y2 = scan.nextDouble();
9double x3 = input.nextDouble(); 9double x3 = scan.nextDouble();
10double y3 = input.nextDouble(); 10double y3 = scan.nextDouble();
11double Area=Math.abs((x1*y2)+(x2*y3)+(x3*y1)-(x2*y1)-(x3*y2)-(x1*y3))/2; 11double s=(x1*y2+y1*x3+y3*x2-y2*x3-y1*x2-x1*y3)/2;
12Area=Math.floor(Area*10)/10; 12if(s<0) {
13System.out.printf("%.1f\n",Area); 13s= -s;
   14}
   15System.out.printf("%.1f\n",(int)(s*10)/10.0);
14} 16} 
15} 17} 
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double x1 = input.nextDouble();
double y1 = input.nextDouble();
double x2 = input.nextDouble();
double y2 = input.nextDouble();
double x3 = input.nextDouble();
double y3 = input.nextDouble();
double Area=Math.abs((x1*y2)+(x2*y3)+(x3*y1)-(x2*y1)-(x3*y2)-(x1*y3))/2;
Area=Math.floor(Area*10)/10;
System.out.printf("%.1f\n",Area);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double x1 = scan.nextDouble();
double y1 = scan.nextDouble();
double x2 = scan.nextDouble();
double y2 = scan.nextDouble();
double x3 = scan.nextDouble();
double y3 = scan.nextDouble();
double s=(x1*y2+y1*x3+y3*x2-y2*x3-y1*x2-x1*y3)/2;
if(s<0) {
s= -s;
}
System.out.printf("%.1f\n",(int)(s*10)/10.0);
}
}