#include <iostream>
using namespace std;
int max(int a,int b)
{
int t;
if(a<b)
{
t=a;
a=b;
b=t;
}
while(b!=0)
{
t=a%b;
a=b;
b=t;
}
return(a);
}
main()
{
int a1,b1,m;
cout<<"请输入两个整数a1和b1:";
cin>>a1>>b1;
m=max(a1,b1);
cout<<"最大公约数是 "<<m<<endl;
return 0;
using namespace std;
int max(int a,int b)
{
int t;
if(a<b)
{
t=a;
a=b;
b=t;
}
while(b!=0)
{
t=a%b;
a=b;
b=t;
}
return(a);
}
main()
{
int a1,b1,m;
cout<<"请输入两个整数a1和b1:";
cin>>a1>>b1;
m=max(a1,b1);
cout<<"最大公约数是 "<<m<<endl;
return 0;
}