【问题标题】:Runtime execution crash运行时执行崩溃
【发布时间】:2016-02-04 11:46:07
【问题描述】:

我在 Eclipse 中遇到了这个问题,在 Geany 中似乎可以正常工作...

void CopiaMaze( int MazeCopia[][COLUMNS])
{
    int i,j;
    for(i=0; i < ROWS; i++){
        for(j=0; j < COLUMNS; j++){
            cout << "Fila Columna" << i <<j;
            MazeCopia[i][j] = m.getValueMap(i,j);
            cout << "Numero" << MazeCopia[i][j] << endl;
        }
    }
}

我试图复制在这种情况下行 19 列 40 的数组

用途是:

int inteligentMinimax(int jugador)
{

        int minimaxValue=0;
        int mazeTemp[ROWS][COLUMNS];

        fillCharacters();

        bestMovementPath.clear();

        CopiaMaze( mazeTemp);

        cout << "Paso Copia Maze";

        cout << "Characters:" << CharactersLocationsMaze;

        cout << "Minimax Value es: " << minimaxValue << "Depth :" << depth << "jugador:" << jugador;

        //Inicializo Minimax con los puntos del pacman a cero, direccion sin definir 0 y profunidad 10 que es variable global.
        minimaxValue = minimax(mazeTemp, 0, 0, depth, jugador);

        cout << "Minimax Value es: " << minimaxValue << "Direction :" << bestMovementPath[1];

        return bestMovementPath[1];
    }

所以我进入了Copia Maze,我得到的最后结果是:

Fila Columna1833Numero0
Fila Columna1834Numero0
Fila Columna1835Numero0
Fila Columna1836Numero0
Fila Columna1837Numero0
Fila Columna1838Numero0
Fila Columna1839Numero0

其中 Numero 0 是从 m.getvaluemap(i,j) 获取的正确值...

在此之后它应该继续 cout Paso copiamaze,以表明我通过了 copiamaze 功能......但它卡住并崩溃了。

任何帮助将不胜感激..

【问题讨论】:

  • 您显示的代码绝对没有问题。您需要的唯一帮助是帮助编写minimal reproducible example。
  • 请注意,您在 CopiaMazecall 和 minimax 之间的 3 个 cout 没有被刷新,那么您的错误很可能位于 minimax 中。您可以通过endl(使用换行符作为效果)或flush 刷新 cout

标签: c++ linux eclipse


【解决方案1】:

正如@PW 显示的那样,我认为问题出在 CopiaMaze 中,因为程序崩溃了,它会显示消息“Paso Copia Maze”,这只是我通过 CopiaMaze 时要注意的信号。

问题出在 Minimax 代码中,您只需将 cout 更改为 cerr 即可解决问题,您可以注意到错误出现在 minimax 中。那是另一个线程。

感谢您的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-12
    相关资源
    最近更新 更多