微软笔考试题GCD

微软笔试题GCD[解决办法]//非递归辗转相除int gcd(int a,int b){int r0ra%bwhile(r){abbrra%b}r

微软笔试题GCD
微软笔考试题GCD
[解决办法]


//非递归辗转相除
int gcd(int a,int b)
{
    int r=0;
    r=a%b;
    while(r)
    {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}