首页 > 解决方案 > 将网格中的 2 个项目交换为三消游戏

问题描述

我刚刚初始化了一个随机值的网格,现在我想创建一个名为 SwapItem 的函数,它将交换我的网格的 2 个元素

这是我的网格初始化:

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

我正在使用带有 MFC 应用程序的 Visual c++,我将在 View.cpp 中管理鼠标单击,但在我需要创建将交换网格的 2 个值的函数之前,虽然任务看起来很简单,但我不知道如何要做到这一点,你能帮我吗?许多想法

标签: c++mfc

解决方案


推荐阅读