Euclid法求两个数的最大公因数

#include<iostream>
using namespace std;
int GCD(int x, int y) {
    return y == 0 ? x : GCD(y, x % y);
}
int main()
{
    int x, y;
    x=GCD(169, 121);
    cout << "GCD(169,121)的最大公因数为:" << x << endl;
    y = GCD(202, 282);
    cout << "GCD(202,282)的最大公因数为:" << y << endl;
    system("pause");
    return 0;
}

 

posted @ 2021-10-29 02:59  Grit_L。  阅读(38)  评论(0编辑  收藏  举报