问题遇到的现象和发生背景
用蚁群算法解决MTSP问题,动态申请三维数组一直显示溢出
用代码块功能插入代码,请勿粘贴截图
int ***R_best = (int***)malloc(sizeof(int) * NC_max);
memset(R_best, 0, sizeof(int) * NC_max);
for (int i = 0; i < NC_max; i++) {
R_best[i] = (int**)malloc(sizeof(int) * n);
memset(R_best[i], 0, sizeof(int) * n);
for (int j = 0; j < n; j++) {
R_best[i][j] = (int*)malloc(sizeof(int) * n);
memset(R_best[i][j], 0, sizeof(int) * n);
}
}
//int R_best[NC_max][N][N]; //存储每次迭代的最佳路线