编程知识 cdmana.com

Algorithm notes codeup 1818 maximum common divisor

 

#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a, int b){
	return !b? a : gcd(b, a%b);
}
int main(){
	int a, b;
	cin >> a >> b;
	if(a < b) swap(a,b);
	cout << gcd(a,b);
	return 0;
}

版权声明
本文为[necoha_ dexter]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205141355169114.html

Scroll to Top