#include using namespace std; int main() { int m,n,a,b,m1; cout << "请输入两个正整数: "; cin >> m >> n; if(m>n) { a=m; b=n; } else { a=n; b=m; } while(m1!=0) { m1=a%b; a=b; b=m1; } cout << "最大公约数=" << a<<endl; cout << "最小公倍数=" << m*n/a; return 0; }
来源:https://www.cnblogs.com/deadpool520/p/11063483.html