最大公约数的递归代码

Posted on 2009-07-23 11:34  ddos  阅读(287)  评论(0编辑  收藏  举报

原创  [C/C++]最大公约数的递归代码

int zdgys(int a, int b)
{
           int temp = 0;
           if(a < b)
           {
                  temp = a;
                  a = b;
                  b = temp;
           }
    
if(b!=0)
        
return zdgys(b,a%b);
    
return a;
}

Copyright © 2024 ddos
Powered by .NET 9.0 on Kubernetes