标签:style color io amp c return print include
#include <stdio.h>
int gcd(int m,int n)
{
if(n==0) return m;
else return gcd(n,m%n);
}
*************
变形一
int gcd(int m,int n) {
if(m%n==0) return m;
else return gcd(n,m%n);
}
变形二
int gcd(int m,int n) {
return n==0? m : gcd(n,m%n);
}
变形三
int gcd(int m,int n) {
return m%n==0? m : gcd(n,m%n);
}
**************************
****************
int main()
{
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",gcd(x,y));
return 0;
}
int main()
{
int x,y;
while( scanf("%d%d",&x,&y)!=EOF)
printf("%d\n",gcd(x,y));
return 0;
}
int main() {
int x,y;
while( cin>>x>>y)
cout<<gcd(x,y)<<endl;
return 0;
}
int main()
{
int x,y,t;
while( scanf("%d%d",&x,&y)!=EOF)
{ t=gcd(x,y);
printf("%d %d\n",t,x/t *y);---------x*y /t
}
return 0;
}
int main() {
int x,y;
while( scanf("%d%d",&x,&y)!=EOF)
printf("%d %d\n",gcd(x,y), x*y/ gcd(x,y));
return 0;
}
最大公约数 最小公倍数--------专题,布布扣,bubuko.com
标签:style color io amp c return print include
原文地址:http://www.cnblogs.com/2014acm/p/3887336.html