Top baner Big

Your Ad Here

Top Banner

Your Ad Here

Saturday, November 22, 2008

Chess Board

/*Program : Chess Board
Programmer ::fizmhd(MEA) www.mdown.co.cc*/

#include

/**********************************************************************************
A chess board has coordinates (1,1) to (8,8). A Bishop is placed in one of the squares (m,n). Assuming the board to be empty, find the number of possible moves it can make on the board.
eg:
Input: 1, 1
Output: 7
**********************************************************************************/


int main()
{
int x,y,movement=0,a,b;
printf("Enter position of bishop\n");
scanf("%d%d",&x,&y);
if(x>8||y>8)
printf("max possible co-ordinate is 8\n");
else{
a=x;
b=y;
while(x<8&&y<8) x="a;" y="b;">1)
{
x++;
y--;
movement++;
}
x=a;
y=b;
while(x>1&&y>1)
{
x--;
y--;
movement++;
}
x=a;
y=b;
while(x>1&&y<8)
{
x--;
y++;
movement++;
}
printf("no of movements possible for bishop = %d\n",movement);
}
}

No comments:

Easy Hits

EasyHits4U.com - Your Free Traffic Exchange - 1:1 Exchange Ratio, 5-Tier Referral Program. FREE Advertising!

Bottom Square