Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int triangles(int[][] a) {
- int plus = 0;
- for (int i = 0; i < 3; i++) {
- int diag = 1;
- for (int j = 0; j < 3; j++)
- diag *= a[j][(i + j) % 3];
- plus += diag;
- }
- int minus = 0;
- for (int i = 2; i >= 0; i--) {
- int diag = 1;
- for (int j = 0; j < 3; j++)
- diag *= a[j][(i - j + 3) % 3];
- minus += diag;
- }
- return plus - minus;
- }
Advertisement
Add Comment
Please, Sign In to add comment