Input
2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)
Output
输出A与B的最大公约数。
Sample Input
30 105Sample Output
15
#include<stdio.h> //水题,用欧几里得算法
int main()
{
int GCD(int a,int b);
int A,B;
scanf("%d%d",&A,&B);
printf("%d
",GCD(A,B));
return 0;
}
int GCD(int a,int b) //大家最好记住这个模板,不知道算法的可以百度
{
return b==0?a:GCD(b,a%b);
}
...