Really? I'd hate to break this to you; but it's actually a quite large land mammal. Lives in Africa, India and the likes. http://en.wikipedia.org/wiki/Elephant
At least two different chess pieces could be referred to as an elephant. A piece that got to be called bishop was represented as an elephant in ancient chess and is still called so in Persian (pīl) and Russian (slon). Modern Hindi uses elephant (haathi) for a rook.
this is a picture to show how the elephant walk at the chess board.
the squire in any color is the elephant position and the lines in the same colors is its path.
not that the chess board is 8*8. http://www.khadoori.com/forum/uploaded/3_01213849287.jpg
and this is the program :
but it need complete
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void main()
{
int x,y;
cout<<"Enter the position of the elephant in the chess:\nX-axis: ";
cin>>x
cout<<"\nY-axis: ";
cin>>y;
if (x<0 || x>8 || y<0 || y>8)
cout<<"Erorr!!!";
else
{
}
}
You'll have to watch your bounds on line 8. The chessboard, from the user's point of view, is 1..8, not 0..8. Once you get the input, then transform the input to 0..7 to match your 'computer chessboard'.
int main()
{
int x, y;
// Get (x,y) from user
cout << "Enter the position of the elephant in the chess:\nX-axis (1-8): ";
cin >> x;
cout << "\nY-axis (1-8): ";
cin >> y;
// Make sure (x,y) are correct.
if (x<1 || x>8 || y<1 || y>8)
{
cout << "Error!!!\n";
return 0;
}
// Adjust (x,y) to fit in range [0,7]
x = x-1;
y = y-1;
// Now, the chess board is 0..7, 0..7
// 0 1 2 3 4 5 6 7
// 0 . . . . . . . .
// 1 . . . . . . . * 'E' is the position of the Elephant if the user entered 6,4 --> 5,3
// 2 * . . . . . * . '*' is where it can move
// 3 . * . . . * . .
// 4 . . * . * . . .
// 5 . . . E . . . . So, how do you want to display this information?
// 6 . . * . * . . .
// 7 . * . . . * . .
return 0;
}