
- 计算最大公约数(辗转相除法)
// C++
#include
#include
using namespace std;
int test_way1(int Num1,int Num2){
int tmp;
if(Num1
附上使用Python递归解法:
def gcd(a,b):
while b!=0:
b,a = a%b,b
return a
print(gcd(10,20))
欢迎分享,转载请注明来源:内存溢出

// C++
#include
#include
using namespace std;
int test_way1(int Num1,int Num2){
int tmp;
if(Num1
附上使用Python递归解法:
def gcd(a,b):
while b!=0:
b,a = a%b,b
return a
print(gcd(10,20))
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)