【发布时间】:2018-04-11 20:45:56
【问题描述】:
我在访问二维数组时遇到了困难。我将int** s(s 是二维维度) 作为参数传递。我尝试使用表单下方的索引重用它的元素(s[sp][jc],我也尝试了*(*(s+sp)+jc)),这会出错(没有错误代码,只是关闭程序)。有什么问题?或者如果我可以'不使用二维数组作为参数,而不是我如何打印父序列和矩阵链乘法的矩阵 --> 像这样:((a(bc))((de)f))。
void printParenthesis(int sp, int ep, int jc, int** s) {
printf("Debug\n");
if(sp==ep) {
printf("( %d ", sp);
return;
}
else {
printParenthesis(sp, jc, s[sp][jc], s);
printParenthesis(jc+1, ep, s[jc+1][ep], s);
printf(") ");
}
}
int main() {
...
int s[matNum-1][matNum]
...
printParenthesis(0, matNum, jc, (int**)s);
【问题讨论】:
-
int **不是int[][]
标签: c multidimensional-array parameter-passing matrix-multiplication chain