/******************************************************************************

Sample code for requesting user input to place an object onto two-dimensional 
space within a 5x5 matrix.

*******************************************************************************/
#include <iostream>
#include <cstdlib>

using namespace std;

int GetRow();   //Asks user for row number 1-5
int GetCol();   //Asks user for col number 1-5
void PrintArray(int URow, int UCol);    //Prints out array using user values

int main()
{
    int Row, Col;   //declares two integer type variables for row, column
    Row = 0;        //initializes row to be 0
    Col = 0;        //initializes col to be 0
    
    cout << "Please indicate where you would to place your object in the "
         << endl << "following questions. Please use value 1 to 5 when making "
         << endl << "your choice." << endl;
    Row = GetRow();
    Col = GetCol();
    PrintArray(Row, Col);

    return 0;
}
int GetRow()
{
    int r;  //temp variable to hold user input.
    
    cout << "Please enter which row you would like to place your object: ";
    cin >> r;
    
    return r;
}
int GetCol()
{
    int c;  //temp variable to hold user input.
    
    cout << "Please enter which column you would like to place your object: ";
    cin >> c;
    
    return c;
}
void PrintArray(int URow, int UCol)
{
    char Arr[5][5];  //declaration of 5x5 int type array
    
    for (int i = 0; i < 5; i++)  //iterates through row values
    {
        for (int j = 0; j < 5; j++)  //iterates through col values
        {
            if (i == (URow - 1) && j == (UCol - 1)) //matching condition
            {
                Arr[i][j] = 'O';    //Object placement output
            }
            else
                Arr[i][j] = '.';    //Non-object placement output
            
            cout << Arr[i][j];
        }
        cout << "\n";
    }
}

