#include<iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
while(min(x,y)!=0){
if(x/y!=0) x%=y;
else y%=x;
}
cout<<max(x,y)<<endl;
return 0;
}
辗转相除法C++
最新推荐文章于 2023-07-16 11:20:02 发布
#include<iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
while(min(x,y)!=0){
if(x/y!=0) x%=y;
else y%=x;
}
cout<<max(x,y)<<endl;
return 0;
}