请教下C语言高手,程序老是报错 `a' was not declared in this scope
10.编写…个程序,声明一个3x5的数组并初始化,具体数值可以随意。程序打印出数值,然后数值翻1番,接着再次打印出新值。编写一个函数来显示数组的内容,再编写另一个函数执行...
10.编写…个程序,声明一个3x5的数组并初始化,具体数值可以随意。程序打印出数值,然后数值翻1番,接着再次打印出新值。编写一个函数来显示数组的内容,再编写另一个函数执行翻倍功能。数组名和数组行数作为参数由程序传递给函数。
#include<stdio.h>
#include<stdlib.h>
#define SIZE1 3
#define SIZE2 5
void mul(int a, int b, double arr[a][b]);
void echo(int a,int b,double arr[a][b]);
int main(void)
{
double one[SIZE1][SIZE2] =
{
{1.1,2.2,3.3,4.4,5.5},
{6.6,7.7,8.8,9.9,10.10},
{11.11,12.12,13.13,14.14,15.15}
};
echo(SIZE1, SIZE2, one);
mul(SIZE1, SIZE2, one);
echo(SIZE1, SIZE2, one);
system("pause");
return 0;
}
void mul(int a, int b, double arr[a][b])
{
int i,n;
for(i = 0;i < a;i++)
{
for(n = 0;n < b;n++)
arr[i][n] *= 2;
};
}
void echo(int a, int b, double arr[a][b])
{
int i,n;
for(i = 0;i < a;i++)
{
printf("\n[%d]\n",i);
for(n = 0;n < b;n++)
printf("%7lg",arr[i][n]);
};
}
编译器用的是dev c++,望高手指点
5: error: `a' was not declared in this scope
5: error: `b' was not declared in this scope
6: error: `a' was not declared in this scope
6: error: `b' was not declared in this scope
In function `int main()':
6: error: too many arguments to function `void echo(int, int)'
16: error: at this point in file
5: error: too many arguments to function `void mul(int, int)'
17: error: at this point in file
6: error: too many arguments to function `void echo(int, int)'
18: error: at this point in file
At global scope:
22: error: `a' was not declared in this scope
22: error: `b' was not declared in this scope
In function `void mul(int, int)':
28: error: `arr' undeclared (first use this function)
28: error: (Each undeclared identifier is reported only once for each function it appears in.)
At global scope:
31: error: `a' was not declared in this scope
31: error: `b' was not declared in this scope
In function `void echo(int, int)':
38: error: `arr' undeclared 展开
#include<stdio.h>
#include<stdlib.h>
#define SIZE1 3
#define SIZE2 5
void mul(int a, int b, double arr[a][b]);
void echo(int a,int b,double arr[a][b]);
int main(void)
{
double one[SIZE1][SIZE2] =
{
{1.1,2.2,3.3,4.4,5.5},
{6.6,7.7,8.8,9.9,10.10},
{11.11,12.12,13.13,14.14,15.15}
};
echo(SIZE1, SIZE2, one);
mul(SIZE1, SIZE2, one);
echo(SIZE1, SIZE2, one);
system("pause");
return 0;
}
void mul(int a, int b, double arr[a][b])
{
int i,n;
for(i = 0;i < a;i++)
{
for(n = 0;n < b;n++)
arr[i][n] *= 2;
};
}
void echo(int a, int b, double arr[a][b])
{
int i,n;
for(i = 0;i < a;i++)
{
printf("\n[%d]\n",i);
for(n = 0;n < b;n++)
printf("%7lg",arr[i][n]);
};
}
编译器用的是dev c++,望高手指点
5: error: `a' was not declared in this scope
5: error: `b' was not declared in this scope
6: error: `a' was not declared in this scope
6: error: `b' was not declared in this scope
In function `int main()':
6: error: too many arguments to function `void echo(int, int)'
16: error: at this point in file
5: error: too many arguments to function `void mul(int, int)'
17: error: at this point in file
6: error: too many arguments to function `void echo(int, int)'
18: error: at this point in file
At global scope:
22: error: `a' was not declared in this scope
22: error: `b' was not declared in this scope
In function `void mul(int, int)':
28: error: `arr' undeclared (first use this function)
28: error: (Each undeclared identifier is reported only once for each function it appears in.)
At global scope:
31: error: `a' was not declared in this scope
31: error: `b' was not declared in this scope
In function `void echo(int, int)':
38: error: `arr' undeclared 展开
7个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询