Problem: The queen on the ACSL chess board is the most versatile piece. It can move at most N cells (where N is determined at the start of each game) in the following directions:
1. Left or Right to the borders of the chess board
2. Up or Down to the borders of the chess board
3. Diagonally to the borders of the chess board
r/c12345
5
4
3
2
1
Since the queen can range in so many directions to capture an opponent’s pieces, where can those pieces be safely placed? The ACSL chess board will be a 5x5 grid as labeled and shown above.
Input: There will be five lines of input. Each line will give the location of the queen as an ordered pair in a row, column order and the value of N.
Output: Print the number of locations where a chess piece is safe from capture.
This assignment is a competition program but only if i turn it in before 1:38 February 13-2012 and I'm not intending to...I'm just trying to understand where to go about after this
THIS IS WHAT I GOT SO FAR:
#include<iostream>
using namespace std;
void input(double &x,double &y,double &N)
{
cout<<"Plug in an x,y,and N value."<<endl;
cin>>(x,y);
cin>>N;
}
void output(double &safe,double &x,double &y)
{
if((x,y)=(5,1))
{
}
}
int main()
{
double safe;
input(x,y,N);
output(safe);
}
Accepts 1 input line-x,y,N
Create a 5x5 array containing all 1's.
Translates the coordinates onto the array, store a 0 at that location.
Use a few loops to 'draw' lines of 0's where the queen can move.
*Don't forget to watch out for the edges of the board.
After all your lines are done, count the number of 1's left-this is the output forthis configuration
In the main function...
1 2 3
Get the 5 inputs.
Using a loop, or just batch style, call the above function for each input.
Display the function result.