Pagini recente » Cod sursa (job #1771609) | Cod sursa (job #2004616) | Cod sursa (job #1921197) | Cod sursa (job #94619) | Cod sursa (job #2448112)
/*
* 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
*/
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);
*/
Scanner scanner = new Scanner(new FileInputStream("aria.in"));
PrintStream writer = new PrintStream("aria.out");
String line_1 = "";
String line_2 = "";
String[] cuv;
String[] cuv_2;
int sum = 0;
int N = Integer.parseInt(scanner.nextLine());
for (int i = 0; i < N / 2; i++) {
line_1 = scanner.nextLine();
line_2 = scanner.nextLine();
cuv = line_1.split(" ");
cuv_2 = line_2.split(" ");
sum += Integer.parseInt(cuv[0]) * Integer.parseInt(cuv_2[1]) - Integer.parseInt(cuv_2[0]) * Integer.parseInt(cuv[1]);
}
if (N % 2 == 1) {
line_1 = line_2;
line_2 = scanner.nextLine();
cuv_2 = line_2.split(" ");
cuv = line_1.split(" ");
sum += Integer.parseInt(cuv[0]) * Integer.parseInt(cuv_2[1]) - Integer.parseInt(cuv_2[0]) * Integer.parseInt(cuv[1]);
}
writer.println(sum);
}
}