辗转相减求最大公约数

#include   <iostream>
int main()
{
    using namespace std;
int m, n;
cin >> n >> m;
    while (m != n)
    {
        while (m>n) { m = m - n; }
        while (n>m) { n = n - m; }
    }
    printf("%d
", m);
    system("pause");
    return 0;
}

运行结果:

原文地址:https://www.cnblogs.com/Mr210843013/p/4823549.html