#include<iostream> using namespace std; int main() { int m,n,Max; int temp1,temp2; cout<<"please input two numbers:"<<endl; cin>>m>>n; Max=(m>n)?m:n; for(int i=1;i<Max;i++) { if(m%i==0&&n%i==0) { temp1=i; } } cout<<"最大公约数为:"<<temp1<<endl; temp2 = m * n / temp1; cout<<"最小公倍数为:"<<temp2<<endl; return 0; }