[求助]多维数组做函数参数
#include "stdio.h" void fm();
main()
{
int a[10][10],n,i,j;
FILE *fp;
if((fp=fopen("test-2.txt","w"))==NULL)printf("Can't open the file!\n");
printf("please input a number n(2<=n<=9):");
scanf("%d",&n);
printf("\n");
fm(a,n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
fprintf(fp,"%d\t",a[i][j]);
}
printf("\n");
fprintf(fp,"\n");
}
fclose(fp);
getch();
}
void fm(int a[][10],int m)
{
int i,j;
for(i=0;i<m;i++){a[0][i]=i+1;a[i][0]=i+1;}
for(i=1;i<m;i++)
for(j=1;j<m;j++)a[i][j]=a[i][j-1]+a[i][0];
}
红色部分如果不填数字就会出错,为什么呢?
[此贴子已经被作者于2007-10-25 10:34:03编辑过]