Pagini recente » Cod sursa (job #2591119) | Cod sursa (job #452248) | Cod sursa (job #1528599) | Cod sursa (job #1819828) | Cod sursa (job #2448137)
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
/**
*
* @author dakata
*/
class Puncte {
double x;
double y;
public Puncte(double x, double y) {
this.x = x;
this.y = y;
}
}
public class Main {
/**
* @param args the command line arguments
*/
/*
public static void main(String[] args) throws FileNotFoundException {
// TODO code application logic here
Scanner scanner = new Scanner(new FileInputStream("adunare.in"));
PrintStream writer = new PrintStream("adunare.out");
int a = Integer.parseInt(scanner.nextLine());
int b = Integer.parseInt(scanner.nextLine());
writer.println(a+b);
}
*/
public static void main(String[] args) throws FileNotFoundException {
Scanner scanner = new Scanner(new FileInputStream("aria.in"));
PrintStream writer = new PrintStream("aria.out");
double sum = 0;
int N = Integer.parseInt(scanner.nextLine());
Puncte[] puncte = new Puncte[N + 1];
for (int i = 0; i < N; i++) {
String line = scanner.nextLine();
String[] cuv = line.split(" ");
puncte[i] = new Puncte(Double.parseDouble(cuv[0]), Double.parseDouble(cuv[1]));
}
puncte[N] = puncte[0];
for (int i = 0; i < N; i++) {
sum += puncte[i].x * puncte[i + 1].y - puncte[i + 1].x * puncte[i].y;
}
writer.printf("%.5f\n",sum / 2);
}
}