#include “stdio.h”
main()
{int s[100][100],n,i,j,sum;
scanf(“n=%d”,&n);
for (i=0;i<=n;i++)
{for(j=0;j<=n;j++)
scanf(“%d”,&s[i][j]);
}
sum=getsum(s[n][n],n);
printf(“sum=%d”,sum);
}
int getmax(a,b)
int a,b;
{int c,n,max;
if(a<b){n=a;a=b;b=n;}
do
{ n=a%b;
a=b;
b=n;
}while (n!=0);
max=a;
return(max);
}
int getmin(a,b)
int a,b;
{int max,min;
max=getmax(a,b);
min=a*b/max;
return (min);
}
int getsum(s,n)
int s[100][100],n;
{int a,b,min,s1[100][100];
int n1,n2,i,j,sum;
if (n>=2)
{
a=s[0][0];
for(i=1;i<=n;i++)
{
b=s[i][0];
min=getmin(a,b);
n1=min/a;
n2=min/b;
for(j=0;j<=n;j++)
s1[i][j]=s[i][j]*n2-s[0][j]*n1;
}
for(i=0;i<=n-1;i++)
for(j=0;j<=n-1;j++)
{if(i==0)
s[i][j]=s1[i+1][j]*a;
else s[i][j]=s1[i+1][j];
}
s[n-2][n-2]=getsum(s[n-1][n-1],n-1);
}
else
sum=s[0][0]*s[1][1]-s[1][0]*s[0][1];
return (sum);
不知什么原因变成死循环了,求那位大哥帮我解答。急
>> 本文固定链接: http://www.vcgood.com/archives/2218