Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 332443e

Browse filesBrowse files
Completed
1 parent ff538f4 commit 332443e
Copy full SHA for 332443e

File tree

1 file changed

+40
-0
lines changed
Filter options

1 file changed

+40
-0
lines changed
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* ChessQueenMoves
3+
*/
4+
// import java.util.*;
5+
public class ChessQueenMoves {
6+
7+
public static void main(String[] args) {
8+
// Scanner sc = new Scanner(System.in);
9+
int row = 8, col = 8;
10+
int sourceRow = 2, sourceCol = 1;
11+
int board[][] = new int[row][col];
12+
for (int i = 0; i < row; i++) {
13+
for (int j = 0; j < col; j++) {
14+
if (i == sourceRow && j == sourceCol)
15+
board[i][j] = 1;
16+
else
17+
board[i][j] = 0;
18+
System.out.print(board[i][j] + " ");
19+
}
20+
System.out.println();
21+
}
22+
System.out.println();
23+
int drow = 1, dcol = 0;
24+
if (drow == sourceRow || sourceCol == dcol || drow + dcol == sourceRow + sourceCol
25+
|| drow - dcol == sourceRow - sourceCol) {
26+
System.out.println("valid");
27+
for (int i = 0; i < row; i++) {
28+
for (int j = 0; j < col; j++) {
29+
if (i == drow && j == dcol)
30+
board[i][j] = 1;
31+
else
32+
board[i][j] = 0;
33+
System.out.print(board[i][j] + " ");
34+
}
35+
System.out.println();
36+
}
37+
} else
38+
System.out.println("not valid");
39+
}
40+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.