似乎是二维数组的定义出问题了

做这道题时:
【问题描述】
对于多个N阶矩阵,依次进行加、减运算。

【输入形式】
从标准输入读取输入。第一行只有一个整数N(1≤N≤10),代表矩阵的阶数。
接下来是一个矩阵,是N行,每行有N个整数(可能是正、负整数),是矩阵的所有元素。
然后一行只含一个字符“+”或“-”,代表加、减操作。
然后用同样的方式输入另一个矩阵。
后续仍然是运算符和矩阵。直至运算符为“#”时停止计算,将结果输出。

【输出形式】
向标准输出打印矩阵的操作结果。输出N行,每行对应矩阵在该行上的所有元素,每一行末均输出一个回车符。每个元素占5个字符宽度(包括负号),向右对齐,不足部分补以空格。
编的程序有下面这部分
int n,
a[n][n]={0},
b[n][n]={0},
c[n][n];
但编译时却出现这些问题:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2087: '<Unknown>' : missing subscript
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2087: '<Unknown>' : missing subscript
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2087: '<Unknown>' : missing subscript
整整15个,且错误都指向那部分代码。
我是菜鸟,向各位求解啊

a[n][n]={0},b[n][n]={0},赋值好像不对,静态数组才默认补0吧
还有是不是因为b[][]是整型数组而你里面的东西是符号的原因?
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-11-24
C语言语法需要学一学。

应该这样定义:

#define N 10

int a[N][N];
int b[N][N];
int c[N][N];
相似回答