Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MAin {
- public static void main(String[] args) {
- int[][] mat = new int[8][8];
- for(int i = 0; i < 8; i++) {
- for(int j = 0; j < 8; j++) {
- mat[i][j] = 0;
- }
- }
- int p = 0;
- for(int i = 0; i < 8; i++) {
- for(int j = 0; j < 8; j++) {
- int ci = i, cj = j;
- while(ci >= 0 && cj >= 0) { // prvata dijagonala, odime levo nagore
- mat[ci][cj] = 1;
- ci--;
- cj--;
- }
- ci = i;
- cj = j;
- while(ci < 8 && cj < 8) { // dole desno
- mat[ci][cj] = 1;
- ci++;
- cj++;
- }
- ci = i;
- cj = j;
- while(ci >= 0 && cj < 8) { // gore desno
- mat[ci][cj] = 1;
- ci--;
- cj++;
- }
- ci = i;
- cj = j;
- while(ci < 8 && cj >= 0) { // dole levo
- mat[ci][cj] = 1;
- ci++;
- cj--;
- }
- for(int a = 0; a < 8; a++) {
- for(int b = 0; b < 8; b++) {
- if(a != i && b != j && mat[a][b] == 0) {
- p++;
- }
- }
- }
- for(int a =0 ; a < 8; a++) {
- for(int b = 0; b < 8; b++) {
- mat[a][b] = 0;
- }
- }
- }
- }
- System.out.println(p / 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement