[求助]老是出现segment fault!
#include<stdio.h>#include<stdlib.h>
int gys(int,int);
int main()
{
int c,m,n,i,j,a,length;
for(scanf("%d",&c);c;c--)
{
scanf("%d%d",&m,&n);
int num1a[m][n],num1b[m][n],num2a[m*n],num2b[m*n];
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
a=gys(i,j);
num1a[i-1][j-1]=i/a;
num1b[i-1][j-1]=j/a;
}
}
num2a[0]=num1a[0][0];
num2b[0]=num1b[0][0];
length=1;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
for(a=0;a<length;a++)
{
if((num1a[i][j]==num2a[a])&&(num1b[i][j]==num2b[a]))
break;
}
if(a==length)
{
num2a[length]=num1a[i][j];
num2b[length]=num1b[i][j];
length++;
}
}
}
printf("%d\n",length);
}
}
int gys(int m,int n){
int r=m%n;
while(r!=0)
{
m=n;
n=r;
r=m%n;
}
return n;
}