0% found this document useful (0 votes)
30 views1 page

Chess Queen Moves

Uploaded by

gowthammeenara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Chess Queen Moves

Uploaded by

gowthammeenara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/**

* ChessQueenMoves
*/
// import java.util.*;
public class ChessQueenMoves {

public static void main(String[] args) {


// Scanner sc = new Scanner(System.in);
int row = 5, col = 5;
int sourceRow = 2, sourceCol = 1;
int board[][] = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (i == sourceRow && j == sourceCol)
board[i][j] = 1;
else
board[i][j] = 0;
System.out.print(board[i][j] + " ");
}
System.out.println();
}
System.out.println();
int drow = 1, dcol = 0;
if (drow == sourceRow || sourceCol == dcol || drow + dcol == sourceRow +
sourceCol
|| drow - dcol == sourceRow - sourceCol) {
System.out.println("valid");
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (i == drow && j == dcol)
board[i][j] = 1;
else
board[i][j] = 0;
System.out.print(board[i][j] + " ");
}
System.out.println();
}
} else
System.out.println("not valid");
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy