#include <iostream>
using namespace std;
int* create2Darray(int rows, int columns);
void set(int *arr, int rows, int columns, int desired_row, int desired_column, int val);
int get(int *arr, int rows, int columns, int desired_row, int desired_column);
int main()
{

    int *arr = create2Darray(10,10);

    for (int i = 0; i < 10; i ++)
    {
        for(int j = 0; j < 10; j ++)
        {
            set(arr, 10, 10, i, j, i*10+j);
        }
    }
    for (int i = 0; i < 10; i ++)
    {
        for(int j = 0; j < 10; j ++)
        {
			if(i == 0 && j == 9)
				cout <<"[0][9]=";//here is the position of the garbage
            cout << get(arr, 10, 10, i, j) << " ";
			
        }
		cout << endl;
    }
    set(arr, 10, 10, 10, 10, 10);
    get(arr, 10, 10, 10, 10);
    return 0;





}

int* create2Darray(int rows, int columns)
{
    return new int(rows * columns);
}

void set(int *arr, int rows, int columns, int desired_row, int desired_column, int val)
{
    if (desired_row<rows&&desired_column<columns&&desired_row>=0&&desired_column>=0)
    {
        arr[desired_row*columns+desired_column] = val;
    }

    else
    {
        cout << "Invalid index!" << endl;
        return;
    }
}

int get(int *arr, int rows, int columns, int desired_row, int desired_column)
{
    if (desired_row<rows&&desired_column<columns&&desired_row>=0&&desired_column>=0)
    {
        return arr[desired_row*columns+desired_column];
    }

    else
    {
        cout << "Invalid index!" << endl;
        system("pause");
        exit(0);
    }
}
