HW I dont understand what im doing wrong

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.

Sample Input:
1. 3,3,2
2. 4,1,1
3. 5,3,2
4. 5,4,3
5. 2,3,1
Sample Output:
1. 8
2. 19
3. 14
4. 13
5. 16

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);
}

Try this...

Create a function that:
1
2
3
4
5
6
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 for this 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.
okay sorry for the late reply but i got some helped and got here:
#include<iostream>
#include<string>


using namespace std;

void input(string &operation)
{
cout<<"Would you like to do?"<<endl;cin>>operation;
}
void output(string &operation)
{
string a;
string b;
if(operation[0]=='D')
{
string cell=operation.erase(0,7);
string b=cell.substr(4,4);
string a=cell.substr(0,4);
cout<<a+a<<"and"<<b+b<<endl;
}
if(operation[0]=='A')
{
int n=operation[3]-48;
string cell=operation.erase(0,4);
string a=cell.substr(n,8-n);
string b=cell.substr(8-n,n);
cout<<a+b<<endl;
}
if(operation[0]=='S')
{
int n=operation[8]-48;
string cell=operation.erase(0,9);
string c=cell;
string a=cell.erase(0,n);
string b=c.erase(0,7-n);
cout<<a<<endl;
cout<<a+b<<endl;
}
}
int main()
{
string operation;

input(operation);
output(operation);


}
Topic archived. No new replies allowed.