|
楼主 |
发表于 2004-10-30 20:58:51
|
显示全部楼层
[code:1] #include <math.h>
int main( )
{
long m,n,r;
scanf("%d,%d",&m,&n);
if(m==n) printf("%d",m);
loop: if(r!=0)
{
if(m>n)
{
r=m%n;
m=n;n=r;goto loop;
}
else if(m<n)
{
r=n%m;
n=m;m=r;goto loop;
}
}
if(r==0)
{
if(m>n)
printf("%d\n",m);
else
printf("%d\n",n);
}
return (0);
}[/code:1]
运行结果:
[fydream@fydream yuandaima]$ gcc -o fy linshi.c
[fydream@fydream yuandaima]$ ./fy
5,5
5[fydream@fydream yuandaima]$ ./fy
24,27
3
[fydream@fydream yuandaima]$ ./fy
2,10
2
万全正确,太好了!今天没有白过,学会了两种算法!真诚得谢谢你们几位得帮助!! |
|