Skip to content

Commit 5255061

Browse files
committed
Create problem20.java
1 parent 302fdf0 commit 5255061

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

problem20.java

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2+
import java.util.Scanner;
3+
4+
/**
5+
* Solved by S.Harshini Sri , IT
6+
*/
7+
8+
/**
9+
* 1 white pawns
10+
* 2 white knights
11+
* 3 white bishops
12+
* 4 white rooks
13+
* 5 white queens
14+
* 6 white king
15+
*
16+
* Black pieces use negative values
17+
* -1 black pawn
18+
* -2 black knight
19+
* -3 black bishops
20+
* -4 black rooks
21+
* -5 black queens
22+
* -6 black king
23+
*
24+
* 8| -4 -2 -3 -5 -6 -3 -2 -4
25+
* 7| -1 -1 -1 -1 -1 -1 -1 -1
26+
* 6| 0 0 0 0 0 0 0 0
27+
* 5| 0 0 0 0 0 0 0 0
28+
* 4| 0 0 0 0 0 0 0 0
29+
* 3| 0 0 0 0 0 0 0 0
30+
* 2| 1 1 1 1 1 1 1 1
31+
* 1| 4 2 3 5 6 3 2 4
32+
* ------------------------
33+
* 1 2 3 4 5 6 7 8
34+
*
35+
*/
36+
public class chess
37+
{
38+
39+
/**
40+
* @param args
41+
*/
42+
public static void main(String[] args)
43+
{
44+
Scanner s=new Scanner(System.in);
45+
int board[][]=new int[8][8];
46+
init(board);
47+
display(board);
48+
49+
50+
}
51+
52+
/**
53+
* @param board
54+
* @return
55+
*/
56+
private static boolean left2up(int[][] board)
57+
{
58+
59+
return false;
60+
}
61+
62+
/**
63+
* @param board
64+
*/
65+
private static void display(int[][] board)
66+
{
67+
for(int i=0;i<8;i++)
68+
{
69+
for(int j=0;j<8;j++)
70+
System.out.print(board[i][j]+"\t");
71+
System.out.println();
72+
}
73+
}
74+
75+
/**
76+
*
77+
*/
78+
private static void init(int arr[][])
79+
{
80+
int x=arr.length;
81+
int y=arr[0].length;
82+
for(int i=0;i<y;i++)
83+
{
84+
arr[1][i]=-1;
85+
arr[6][i]=1;
86+
}
87+
arr[0][0]=-4;
88+
arr[0][7]=-4; // rooks
89+
arr[7][7]=4;
90+
arr[7][0]=4;
91+
92+
arr[0][1]=-2;
93+
arr[0][6]=-2; //knights
94+
arr[7][6]=2;
95+
arr[7][1]=2;
96+
97+
arr[0][2]=-3;
98+
arr[0][5]=-3;
99+
arr[7][2]=3; // bishops
100+
arr[7][5]=3;
101+
102+
arr[0][3]=-5; // queen
103+
arr[7][3]=5;
104+
105+
arr[0][4]=-6; // King
106+
arr[7][4]=6;
107+
}
108+
109+
}

0 commit comments

Comments
 (0)