I just initalized a grid of random value and now I want to create a function named SwapItem that will swap 2 elements of my grid
Here is my grid initialization:
CPlateau::CPlateau()
: m_iColonnes(8)
, m_iLignes(8)
, m_arrPlateau(NULL)
void CPlateau::CreatePlateau()
{
m_arrPlateau = new int*[m_iLignes];
for (int ligne = 0; ligne < m_iLignes; ligne++)
{
m_arrPlateau[ligne] = new int[m_iColonnes];
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = 0;
}
}
void CPlateau::SetupPlateau()
{
if (m_arrPlateau == NULL)
CreatePlateau();
for (int ligne = 0; ligne < m_iLignes; ligne++)
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = (rand() % 7);
}
I'm using visual c++ with MFC aplication, I will manage the mouse click in the View.cpp but before I need to create the function that will swap 2 value of my grid, although the task seems simple,I have no idea of how to do it, can you help me? Many thks