关于欧几里得算法的解析:
题目:
#include <iostream>
#include <algorithm>
using namespace std;
// int gcd(int a, int b)
// {
// //根据欧几里得算法:g(a, b) = (b, a % b)
// return b ? gcd(b, a % b) : a;
// 等价于下面的写法
// //if(b == 0) return a;
// //return gcd(b, a % b);
// }
int main()
{
int n = 0;
cin >> n;
while(n--)
{
int x = 0, y = 0;
cin >> x >> y;
//cout << gcd(x, y) << endl;
//使用头文件<algorithm>里面包含的库函数__gcd()
cout << __gcd(x, y) << endl;
}
return 0;
}