File tree 1 file changed +40
-0
lines changed
Filter options
1 file changed +40
-0
lines changed
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments